fix contact email and automate landing deploy #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Container | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| concurrency: | |
| group: landing-production | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| publish: | |
| name: Build and publish | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Generate image metadata | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=branch | |
| type=sha,prefix=sha- | |
| type=raw,value=latest,enable=${{ github.ref_name == 'main' }} | |
| - name: Build and push image | |
| id: build | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Configure restricted deployment key | |
| env: | |
| VPS_DEPLOY_KEY: ${{ secrets.VPS_DEPLOY_KEY }} | |
| VPS_HOST_KEY: ${{ secrets.VPS_HOST_KEY }} | |
| run: | | |
| install -d -m 0700 ~/.ssh | |
| printf '%s\n' "$VPS_DEPLOY_KEY" > ~/.ssh/landing_deploy | |
| printf '%s\n' "$VPS_HOST_KEY" > ~/.ssh/known_hosts | |
| chmod 0600 ~/.ssh/landing_deploy ~/.ssh/known_hosts | |
| - name: Deploy landing only | |
| env: | |
| IMAGE_DIGEST: ${{ steps.build.outputs.digest }} | |
| VPS_HOST: ${{ secrets.VPS_HOST }} | |
| VPS_USER: ${{ secrets.VPS_USER }} | |
| run: | | |
| started_ms=$(date +%s%3N) | |
| image="ghcr.io/${GITHUB_REPOSITORY}@${IMAGE_DIGEST}" | |
| printf 'TIMING deploy_request_started_at=%s\n' "$(date --iso-8601=milliseconds)" | |
| ssh \ | |
| -i ~/.ssh/landing_deploy \ | |
| -o BatchMode=yes \ | |
| -o IdentitiesOnly=yes \ | |
| "${VPS_USER}@${VPS_HOST}" \ | |
| "deploy-landing ${image} ${GITHUB_SHA} ${GITHUB_RUN_ID}" | |
| printf 'TIMING deploy_request_ms=%s\n' "$(( $(date +%s%3N) - started_ms ))" |