name: Docker on: push: branches: [ "main" ] # Publish semver tags as releases. tags: [ 'v*.*.*' ] pull_request: branches: [ "main" ] jobs: build: runs-on: alrest-xe-site permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log into registry if: github.event_name != 'pull_request' uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 with: registry: ghcr.io username: xe password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push if: github.event_name != 'pull_request' id: build uses: docker/bake-action@v6 with: source: . push: true set: | patreon-saasproxy.tags=ghcr.io/xe/site/patreon-saasproxy:latest xesite.tags=ghcr.io/xe/site/bin:latest - name: Build Docker image if: github.event_name == 'pull_request' uses: docker/bake-action@v6 with: source: . push: false set: | patreon-saasproxy.tags=ghcr.io/xe/site/patreon-saasproxy:latest xesite.tags=ghcr.io/xe/site/bin:latest deploy: name: "Deploy xesite" needs: build runs-on: alrest-xe-site if: github.ref == 'refs/heads/main' permissions: contents: read steps: - uses: actions/checkout@v4 - uses: dorny/paths-filter@v3 id: changes with: filters: | src: - 'cmd/**/*.go' - 'internal/**/*.go' - 'pb/*' - 'pb/**/*' - 'go.mod' - 'go.sum' - 'docker/*' - "docker-bake.hcl" - 'manifest/**/*.yaml' - uses: azure/setup-kubectl@v4 if: steps.changes.outputs.src == 'true' - name: Save Civo kubeconfig if: steps.changes.outputs.src == 'true' run: | curl -sL https://civo.com/get | sudo sh civo apikey add default $CIVO_TOKEN civo apikey current default civo kubernetes config --region phx1 aeacus --save --switch env: CIVO_TOKEN: ${{ secrets.CIVO_TOKEN }} - name: "Deploy" if: steps.changes.outputs.src == 'true' run: | kubectl apply -k manifest kubectl rollout restart -n default deploy/xesite