|
| 1 | +name: Periodically rebuild & publish containers (auto update) |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # run once a day at 21:50 UTC |
| 6 | + - cron: '50 21 * * *' |
| 7 | + |
| 8 | +concurrency: build |
| 9 | + |
| 10 | +env: |
| 11 | + CI_TOOLS_SETUP: https://raw.githubusercontent.com/SGSGermany/ci-tools/main/setup.sh |
| 12 | + |
| 13 | +defaults: |
| 14 | + run: |
| 15 | + shell: bash -eu -o pipefail {0} |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + packages: write |
| 23 | + |
| 24 | + env: |
| 25 | + REGISTRY: ghcr.io |
| 26 | + OWNER: sgsgermany |
| 27 | + IMAGE: butane |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Setup CI tools |
| 31 | + run: | |
| 32 | + . <(curl -fsS -L "$CI_TOOLS_SETUP" | bash -s ~/ci-tools) |
| 33 | + echo "CI_TOOLS=$CI_TOOLS" | tee -a "$GITHUB_ENV" |
| 34 | + echo "CI_TOOLS_PATH=$CI_TOOLS_PATH" | tee -a "$GITHUB_ENV" |
| 35 | +
|
| 36 | + - name: Checkout repository |
| 37 | + uses: actions/checkout@v4 |
| 38 | + |
| 39 | + - name: Log into container registry ${{ env.REGISTRY }} |
| 40 | + uses: redhat-actions/podman-login@v1 |
| 41 | + with: |
| 42 | + registry: ${{ env.REGISTRY }} |
| 43 | + username: ${{ github.actor }} |
| 44 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + |
| 46 | + - name: Generate container image tags |
| 47 | + run: | |
| 48 | + source <(./tags.sh "$GITHUB_RUN_ID.$GITHUB_RUN_NUMBER") |
| 49 | + echo "MILESTONE=$MILESTONE" | tee -a "$GITHUB_ENV" |
| 50 | + echo "VERSION=$VERSION" | tee -a "$GITHUB_ENV" |
| 51 | + echo "TAGS=$TAGS" | tee -a "$GITHUB_ENV" |
| 52 | +
|
| 53 | + - name: Check for updates |
| 54 | + run: | |
| 55 | + BUILD_ACTION="$(./check-for-updates.sh)" |
| 56 | + echo "BUILD_ACTION=$BUILD_ACTION" | tee -a "$GITHUB_ENV" |
| 57 | +
|
| 58 | + - name: Build container image |
| 59 | + if: ${{ env.BUILD_ACTION != '' }} |
| 60 | + run: | |
| 61 | + buildah unshare ./build.sh |
| 62 | +
|
| 63 | + - name: Container image metadata |
| 64 | + run: | |
| 65 | + "$CI_TOOLS_PATH/containers/get-metadata.sh" "$REGISTRY/$OWNER" "$IMAGE:${TAGS%% *}" |
| 66 | +
|
| 67 | + - name: Push container image |
| 68 | + if: ${{ env.BUILD_ACTION != '' }} |
| 69 | + uses: redhat-actions/push-to-registry@v2 |
| 70 | + with: |
| 71 | + image: ${{ env.IMAGE }} |
| 72 | + registry: ${{ env.REGISTRY }}/${{ env.OWNER }} |
| 73 | + tags: ${{ env.TAGS }} |
0 commit comments