Adds .github/workflows/deploy.yml: on a v* tag (ermite only), build the image, push it to Gordon's CI host and gordon apps set-image that digest. The job runs in the production environment; no Gordon secret is stored, Gordon trusts only repo:bnema/sharm:environment:production for its app/service/repository. Outdated actions move to their current major tags.
#1 ci(deploy): deploy v* tags to Gordon with OIDC
A .github/workflows/deploy.yml +68 -0
| @@ -0,0 +1,68 @@ | |||
| 1 | + | # Deploys a tagged release to Gordon: builds the image, pushes it to Gordon's | |
| 2 | + | # CI host with this job's OIDC identity and runs exactly that digest in one | |
| 3 | + | # service. No Gordon secret is stored in the repository: Gordon accepts only | |
| 4 | + | # the subject repo:bnema/sharm:environment:production, for this app, service | |
| 5 | + | # and image repository. | |
| 6 | + | name: Deploy | |
| 7 | + | ||
| 8 | + | on: | |
| 9 | + | push: | |
| 10 | + | tags: ['v*'] | |
| 11 | + | ||
| 12 | + | permissions: | |
| 13 | + | contents: read | |
| 14 | + | ||
| 15 | + | concurrency: | |
| 16 | + | group: deploy-production | |
| 17 | + | cancel-in-progress: false | |
| 18 | + | ||
| 19 | + | jobs: | |
| 20 | + | deploy: | |
| 21 | + | name: Deploy | |
| 22 | + | # Tags are mirrored to GitHub; only ermite deploys. | |
| 23 | + | if: github.server_url != 'https://github.com' | |
| 24 | + | runs-on: ubuntu-latest | |
| 25 | + | environment: production | |
| 26 | + | permissions: | |
| 27 | + | contents: read | |
| 28 | + | id-token: write | |
| 29 | + | env: | |
| 30 | + | GORDON_VERSION: v3.6.0 | |
| 31 | + | # gordon_linux_amd64.tar.gz in the checksums.txt of that gordon release. | |
| 32 | + | GORDON_SHA256: 3eae9ef79a6b0dcc4fb42f4a1bd745d6a2857a474a0dab07f17e976f7aa75a40 | |
| 33 | + | GORDON_REMOTE: https://ci.bnema.dev | |
| 34 | + | GORDON_OIDC_AUDIENCE: https://ci.bnema.dev | |
| 35 | + | steps: | |
| 36 | + | - uses: actions/checkout@v7 | |
| 37 | + | with: | |
| 38 | + | persist-credentials: false | |
| 39 | + | - name: Install gordon | |
| 40 | + | run: | | |
| 41 | + | set -euo pipefail | |
| 42 | + | archive=gordon_linux_amd64.tar.gz | |
| 43 | + | curl -fsSL -o "$RUNNER_TEMP/$archive" \ | |
| 44 | + | "https://git.bnema.dev/gordon/releases/download/$GORDON_VERSION/$archive" | |
| 45 | + | echo "$GORDON_SHA256 $RUNNER_TEMP/$archive" | sha256sum -c - | |
| 46 | + | tar -xzf "$RUNNER_TEMP/$archive" -C "$RUNNER_TEMP" gordon | |
| 47 | + | sudo install -m 0755 "$RUNNER_TEMP/gordon" /usr/local/bin/gordon | |
| 48 | + | gordon version | head -1 | |
| 49 | + | # gordon reads ACTIONS_ID_TOKEN_REQUEST_URL/TOKEN itself and exchanges | |
| 50 | + | # the ID token at the CI host. Only the repository and digest are logged. | |
| 51 | + | - name: Build and push | |
| 52 | + | id: push | |
| 53 | + | run: | | |
| 54 | + | set -euo pipefail | |
| 55 | + | gordon images push sharm --build --build-arg VERSION="$GITHUB_REF_NAME" --build-arg COMMIT="$GITHUB_SHA" --build-arg BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)" --tag "$GITHUB_REF_NAME" \ | |
| 56 | + | --remote "$GORDON_REMOTE" --json >push.json | |
| 57 | + | jq -e '.digest | test("^sha256:[0-9a-f]{64}$")' push.json >/dev/null | |
| 58 | + | echo "image=$(jq -r .image push.json)" >>"$GITHUB_OUTPUT" | |
| 59 | + | jq '{repository, tag, digest}' push.json | |
| 60 | + | - name: Set image | |
| 61 | + | env: | |
| 62 | + | IMAGE: ${{ steps.push.outputs.image }} | |
| 63 | + | run: | | |
| 64 | + | set -euo pipefail | |
| 65 | + | gordon apps set-image sharm --service web --image "$IMAGE" \ | |
| 66 | + | --remote "$GORDON_REMOTE" --json >set-image.json | |
| 67 | + | jq '{op, app, status, outcome}' set-image.json | |
| 68 | + | jq -e '.outcome == "success"' set-image.json >/dev/null | |
| @@ -0,0 +1,68 @@ | |||||
| 1 | + | # Deploys a tagged release to Gordon: builds the image, pushes it to Gordon's | |||
| 2 | + | # CI host with this job's OIDC identity and runs exactly that digest in one | |||
| 3 | + | # service. No Gordon secret is stored in the repository: Gordon accepts only | |||
| 4 | + | # the subject repo:bnema/sharm:environment:production, for this app, service | |||
| 5 | + | # and image repository. | |||
| 6 | + | name: Deploy | |||
| 7 | + | ||||
| 8 | + | on: | |||
| 9 | + | push: | |||
| 10 | + | tags: ['v*'] | |||
| 11 | + | ||||
| 12 | + | permissions: | |||
| 13 | + | contents: read | |||
| 14 | + | ||||
| 15 | + | concurrency: | |||
| 16 | + | group: deploy-production | |||
| 17 | + | cancel-in-progress: false | |||
| 18 | + | ||||
| 19 | + | jobs: | |||
| 20 | + | deploy: | |||
| 21 | + | name: Deploy | |||
| 22 | + | # Tags are mirrored to GitHub; only ermite deploys. | |||
| 23 | + | if: github.server_url != 'https://github.com' | |||
| 24 | + | runs-on: ubuntu-latest | |||
| 25 | + | environment: production | |||
| 26 | + | permissions: | |||
| 27 | + | contents: read | |||
| 28 | + | id-token: write | |||
| 29 | + | env: | |||
| 30 | + | GORDON_VERSION: v3.6.0 | |||
| 31 | + | # gordon_linux_amd64.tar.gz in the checksums.txt of that gordon release. | |||
| 32 | + | GORDON_SHA256: 3eae9ef79a6b0dcc4fb42f4a1bd745d6a2857a474a0dab07f17e976f7aa75a40 | |||
| 33 | + | GORDON_REMOTE: https://ci.bnema.dev | |||
| 34 | + | GORDON_OIDC_AUDIENCE: https://ci.bnema.dev | |||
| 35 | + | steps: | |||
| 36 | + | - uses: actions/checkout@v7 | |||
| 37 | + | with: | |||
| 38 | + | persist-credentials: false | |||
| 39 | + | - name: Install gordon | |||
| 40 | + | run: | | |||
| 41 | + | set -euo pipefail | |||
| 42 | + | archive=gordon_linux_amd64.tar.gz | |||
| 43 | + | curl -fsSL -o "$RUNNER_TEMP/$archive" \ | |||
| 44 | + | "https://git.bnema.dev/gordon/releases/download/$GORDON_VERSION/$archive" | |||
| 45 | + | echo "$GORDON_SHA256 $RUNNER_TEMP/$archive" | sha256sum -c - | |||
| 46 | + | tar -xzf "$RUNNER_TEMP/$archive" -C "$RUNNER_TEMP" gordon | |||
| 47 | + | sudo install -m 0755 "$RUNNER_TEMP/gordon" /usr/local/bin/gordon | |||
| 48 | + | gordon version | head -1 | |||
| 49 | + | # gordon reads ACTIONS_ID_TOKEN_REQUEST_URL/TOKEN itself and exchanges | |||
| 50 | + | # the ID token at the CI host. Only the repository and digest are logged. | |||
| 51 | + | - name: Build and push | |||
| 52 | + | id: push | |||
| 53 | + | run: | | |||
| 54 | + | set -euo pipefail | |||
| 55 | + | gordon images push sharm --build --build-arg VERSION="$GITHUB_REF_NAME" --build-arg COMMIT="$GITHUB_SHA" --build-arg BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)" --tag "$GITHUB_REF_NAME" \ | |||
| 56 | + | --remote "$GORDON_REMOTE" --json >push.json | |||
| 57 | + | jq -e '.digest | test("^sha256:[0-9a-f]{64}$")' push.json >/dev/null | |||
| 58 | + | echo "image=$(jq -r .image push.json)" >>"$GITHUB_OUTPUT" | |||
| 59 | + | jq '{repository, tag, digest}' push.json | |||
| 60 | + | - name: Set image | |||
| 61 | + | env: | |||
| 62 | + | IMAGE: ${{ steps.push.outputs.image }} | |||
| 63 | + | run: | | |||
| 64 | + | set -euo pipefail | |||
| 65 | + | gordon apps set-image sharm --service web --image "$IMAGE" \ | |||
| 66 | + | --remote "$GORDON_REMOTE" --json >set-image.json | |||
| 67 | + | jq '{op, app, status, outcome}' set-image.json | |||
| 68 | + | jq -e '.outcome == "success"' set-image.json >/dev/null | |||
M .github/workflows/release-image.yml +6 -5
| @@ -17,10 +17,11 @@ permissions: | |||
| 17 | 17 | ||
| 18 | 18 | jobs: | |
| 19 | 19 | release-image: | |
| 20 | + | if: github.server_url == 'https://github.com' | |
| 20 | 21 | runs-on: ubuntu-latest | |
| 21 | 22 | steps: | |
| 22 | 23 | - name: Checkout | |
| 23 | - | uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| 24 | + | uses: actions/checkout@v7 | |
| 24 | 25 | with: | |
| 25 | 26 | fetch-depth: 0 | |
| 26 | 27 | fetch-tags: true | |
| @@ -78,20 +79,20 @@ jobs: | |||
| 78 | 79 | } >> "$GITHUB_OUTPUT" | |
| 79 | 80 | ||
| 80 | 81 | - name: Set up QEMU | |
| 81 | - | uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4 | |
| 82 | + | uses: docker/setup-qemu-action@v4 | |
| 82 | 83 | ||
| 83 | 84 | - name: Set up Docker Buildx | |
| 84 | - | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 | |
| 85 | + | uses: docker/setup-buildx-action@v4 | |
| 85 | 86 | ||
| 86 | 87 | - name: Log in to GitHub Container Registry | |
| 87 | - | uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 | |
| 88 | + | uses: docker/login-action@v4 | |
| 88 | 89 | with: | |
| 89 | 90 | registry: ghcr.io | |
| 90 | 91 | username: ${{ github.actor }} | |
| 91 | 92 | password: ${{ secrets.GITHUB_TOKEN }} | |
| 92 | 93 | ||
| 93 | 94 | - name: Build and push image | |
| 94 | - | uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6 | |
| 95 | + | uses: docker/build-push-action@v7 | |
| 95 | 96 | with: | |
| 96 | 97 | context: . | |
| 97 | 98 | platforms: linux/amd64,linux/arm64 | |
| @@ -17,10 +17,11 @@ permissions: | |||||
| 17 | 17 | ||||
| 18 | jobs: | 18 | jobs: | ||
| 19 | release-image: | 19 | release-image: | ||
| 20 | + | if: github.server_url == 'https://github.com' | |||
| 20 | runs-on: ubuntu-latest | 21 | runs-on: ubuntu-latest | ||
| 21 | steps: | 22 | steps: | ||
| 22 | - name: Checkout | 23 | - name: Checkout | ||
| 23 | - | uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | 24 | + | uses: actions/checkout@v7 |
| 24 | with: | 25 | with: | ||
| 25 | fetch-depth: 0 | 26 | fetch-depth: 0 | ||
| 26 | fetch-tags: true | 27 | fetch-tags: true | ||
| @@ -78,20 +79,20 @@ jobs: | |||||
| 78 | } >> "$GITHUB_OUTPUT" | 79 | } >> "$GITHUB_OUTPUT" | ||
| 79 | 80 | ||||
| 80 | - name: Set up QEMU | 81 | - name: Set up QEMU | ||
| 81 | - | uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4 | 82 | + | uses: docker/setup-qemu-action@v4 |
| 82 | 83 | ||||
| 83 | - name: Set up Docker Buildx | 84 | - name: Set up Docker Buildx | ||
| 84 | - | uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 | 85 | + | uses: docker/setup-buildx-action@v4 |
| 85 | 86 | ||||
| 86 | - name: Log in to GitHub Container Registry | 87 | - name: Log in to GitHub Container Registry | ||
| 87 | - | uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 | 88 | + | uses: docker/login-action@v4 |
| 88 | with: | 89 | with: | ||
| 89 | registry: ghcr.io | 90 | registry: ghcr.io | ||
| 90 | username: ${{ github.actor }} | 91 | username: ${{ github.actor }} | ||
| 91 | password: ${{ secrets.GITHUB_TOKEN }} | 92 | password: ${{ secrets.GITHUB_TOKEN }} | ||
| 92 | 93 | ||||
| 93 | - name: Build and push image | 94 | - name: Build and push image | ||
| 94 | - | uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6 | 95 | + | uses: docker/build-push-action@v7 |
| 95 | with: | 96 | with: | ||
| 96 | context: . | 97 | context: . | ||
| 97 | platforms: linux/amd64,linux/arm64 | 98 | platforms: linux/amd64,linux/arm64 | ||
Comments00 unresolved
no comments yet.