detached 867c4b8

#1 ci(deploy): deploy v* tags to Gordon with OIDC

state
merged · 867c4b8 · fast-forward
branch
ci/deploy-gordon → main
opened
bnema ·
updated

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.

2 files · +74 -5
6/8
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:
1717
1818 jobs:
1919 release-image:
20+ if: github.server_url == 'https://github.com'
2021 runs-on: ubuntu-latest
2122 steps:
2223 - name: Checkout
23- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
24+ uses: actions/checkout@v7
2425 with:
2526 fetch-depth: 0
2627 fetch-tags: true
@@ -78,20 +79,20 @@ jobs:
7879 } >> "$GITHUB_OUTPUT"
7980
8081 - name: Set up QEMU
81- uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4
82+ uses: docker/setup-qemu-action@v4
8283
8384 - name: Set up Docker Buildx
84- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
85+ uses: docker/setup-buildx-action@v4
8586
8687 - name: Log in to GitHub Container Registry
87- uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
88+ uses: docker/login-action@v4
8889 with:
8990 registry: ghcr.io
9091 username: ${{ github.actor }}
9192 password: ${{ secrets.GITHUB_TOKEN }}
9293
9394 - name: Build and push image
94- uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
95+ uses: docker/build-push-action@v7
9596 with:
9697 context: .
9798 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-latest21 runs-on: ubuntu-latest
21 steps:22 steps:
22 - name: Checkout23 - name: Checkout
23- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v624+ uses: actions/checkout@v7
24 with:25 with:
25 fetch-depth: 026 fetch-depth: 0
26 fetch-tags: true27 fetch-tags: true
@@ -78,20 +79,20 @@ jobs:
78 } >> "$GITHUB_OUTPUT"79 } >> "$GITHUB_OUTPUT"
79 80
80 - name: Set up QEMU81 - name: Set up QEMU
81- uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v482+ uses: docker/setup-qemu-action@v4
82 83
83 - name: Set up Docker Buildx84 - name: Set up Docker Buildx
84- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v385+ uses: docker/setup-buildx-action@v4
85 86
86 - name: Log in to GitHub Container Registry87 - name: Log in to GitHub Container Registry
87- uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v388+ uses: docker/login-action@v4
88 with:89 with:
89 registry: ghcr.io90 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 image94 - name: Build and push image
94- uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v695+ uses: docker/build-push-action@v7
95 with:96 with:
96 context: .97 context: .
97 platforms: linux/amd64,linux/arm6498 platforms: linux/amd64,linux/arm64

Comments00 unresolved

    no comments yet.

    Keyboard shortcuts

    Single-key shortcuts are on. ctrl k and esc work whatever this says.

    ctrl k :
    go to a section, branch, tag, file or repository
    ?
    this list
    j k
    move the row cursor down / up
    enter
    open the row under the cursor; on Files, a directory opens or closes in place
    ↑ ↓ ← → home end
    in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
    l h
    on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. On pages with a side panel: into the panel (on a merge request, its files) / back to the content; there j k move between its controls
    g g G
    first / last row
    /
    filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
    b
    switch branch or tag
    g s g f g c g b g m g i g r g a
    tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
    g h
    home
    w
    wide mode: use the whole width of the screen, or not (remembered)
    y
    copy a permalink pinned to the commit; in a file, click a line number to select it, shift-click for a range
    d u x
    diff: split / unified / collapse or expand all
    e E
    diff: the whole file in view / every file, with the lines the hunks hide
    n
    merge request: next note in the diff
    l
    merge request: the list of files (j k move, enter opens, esc back)
    M
    merge request: the merge menu; there 1–3 pick the mode, D deletes the branch, enter merges
    R
    merge request: mark the head read
    esc
    close a dialog, leave a field

    Branches 2

    Tags 14

    ↑↓ moveenter openesc close