|
| 1 | +# NOT ACTIVE where it sits. Move it into place to enable: |
| 2 | +# git mv themes/vfb-nova/ci/builder-image.yml .github/workflows/builder-image.yml |
| 3 | +# Parked here because the token used to push this branch has no `workflow` |
| 4 | +# scope, and GitHub rejects any push touching .github/workflows/ without it. |
| 5 | +# Pushing from a checkout with normal credentials has no such problem. |
| 6 | +# |
| 7 | +# Until it is moved, virtualflybrain/vfb-static-builder DOES NOT EXIST and the |
| 8 | +# Rancher service has nothing to pull. This has to happen before the switchover. |
| 9 | +# |
| 10 | +# Publishes the image the Rancher build service runs. It lives here, next to |
| 11 | +# deploy.sh, because deploy.sh is what dictates the image's contents — bash, |
| 12 | +# rsync and findutils are in the Dockerfile for its sake. Splitting the two |
| 13 | +# across repos is how rcourt/docsy-builder:Feb2023 ended up frozen on a floating |
| 14 | +# base tag for two years. |
| 15 | +# |
| 16 | +# Uses the org-level Docker Hub secrets (DOCKER_HUB_USER / DOCKER_HUB_PASSWORD), |
| 17 | +# which vfb-status and vfbquery already use to publish into the virtualflybrain |
| 18 | +# namespace. Docker Hub creates the repository on first push. |
| 19 | +name: builder image |
| 20 | + |
| 21 | +on: |
| 22 | + push: |
| 23 | + branches: ["master"] |
| 24 | + paths: |
| 25 | + - "Dockerfile" |
| 26 | + - "deploy.sh" |
| 27 | + - ".github/workflows/builder-image.yml" |
| 28 | + release: |
| 29 | + types: [published] |
| 30 | + workflow_dispatch: |
| 31 | + |
| 32 | +permissions: |
| 33 | + contents: read |
| 34 | + |
| 35 | +jobs: |
| 36 | + publish: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + |
| 41 | + - uses: docker/setup-buildx-action@v3 |
| 42 | + |
| 43 | + - name: Log in to Docker Hub |
| 44 | + uses: docker/login-action@v3 |
| 45 | + with: |
| 46 | + username: ${{ secrets.DOCKER_HUB_USER }} |
| 47 | + password: ${{ secrets.DOCKER_HUB_PASSWORD }} |
| 48 | + |
| 49 | + - name: Metadata |
| 50 | + id: meta |
| 51 | + uses: docker/metadata-action@v5 |
| 52 | + with: |
| 53 | + images: virtualflybrain/vfb-static-builder |
| 54 | + tags: | |
| 55 | + type=raw,value=latest,enable={{is_default_branch}} |
| 56 | + type=ref,event=tag |
| 57 | + type=sha,format=short |
| 58 | +
|
| 59 | + - name: Build and push |
| 60 | + uses: docker/build-push-action@v6 |
| 61 | + with: |
| 62 | + context: . |
| 63 | + push: true |
| 64 | + tags: ${{ steps.meta.outputs.tags }} |
| 65 | + labels: ${{ steps.meta.outputs.labels }} |
| 66 | + |
| 67 | + # Tests the first tag this run actually pushed. The previous version |
| 68 | + # tested :latest, which metadata-action only emits on the default branch, |
| 69 | + # so a tag-triggered run would have failed on an image that did not exist. |
| 70 | + # |
| 71 | + # Pin the Rancher service to the sha- tag printed at the end, not :latest. |
| 72 | + - name: Smoke test the published image |
| 73 | + env: |
| 74 | + TAGS: ${{ steps.meta.outputs.tags }} |
| 75 | + run: | |
| 76 | + set -euo pipefail |
| 77 | + image=$(printf '%s\n' "$TAGS" | head -n1) |
| 78 | + echo "testing $image" |
| 79 | + docker run --rm --entrypoint hugo "$image" version |
| 80 | + docker run --rm --entrypoint /bin/sh "$image" -c ' |
| 81 | + set -e |
| 82 | + command -v bash |
| 83 | + command -v rsync |
| 84 | + command -v find |
| 85 | + test "$HUGO_CACHEDIR" = /tmp/hugo_cache |
| 86 | + test "$(pwd)" = /src |
| 87 | + test "$(id -u)" = 0 |
| 88 | + ' |
| 89 | + echo "pushed tags:" |
| 90 | + printf '%s\n' "$TAGS" |
0 commit comments