Auto-update Build Containers #1867
This file contains 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: Auto-update Build Containers | |
on: | |
push: | |
branches: [main, update-containers/*] | |
schedule: | |
- cron: "0 */2 * * */1" | |
jobs: | |
build-containers: | |
if: github.repository_owner == 'STBoyden' | |
name: Build container for ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- debian-latest | |
- debian-sid | |
- fedora-latest | |
- fedora-rawhide | |
- rhel-8 | |
- rhel-latest | |
- ubuntu-20-04 | |
- ubuntu-latest | |
runs-on: ubuntu-22.04 | |
permissions: | |
packages: write | |
steps: | |
- run: echo "DATE=$(date +%d%m%Y_%H%M%S)" >> "$GITHUB_ENV" | |
- uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ github.token }} | |
- name: Build for ${{ matrix.os }} | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./.github/containers/${{ matrix.os }} | |
platforms: linux/amd64 | |
push: false | |
load: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: | | |
ghcr.io/stboyden/codectrl-pkg/${{ matrix.os }}:latest | |
ghcr.io/stboyden/codectrl-pkg/${{ matrix.os }}:${{ github.sha }} | |
ghcr.io/stboyden/codectrl-pkg/${{ matrix.os }}:${{ env.DATE }} | |
- name: Push for ${{ matrix.os }} | |
run: | | |
set -x | |
docker push ghcr.io/stboyden/codectrl-pkg/${{ matrix.os }}:latest | |
docker push ghcr.io/stboyden/codectrl-pkg/${{ matrix.os }}:${{ github.sha }} | |
docker push ghcr.io/stboyden/codectrl-pkg/${{ matrix.os }}:${{ env.DATE }} | |
set +x | |
echo "Pushed!" | |
echo "Pushed the following tags for ${{ matrix.os }}'s container" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "- \`${{ github.sha }}\` -- The commit that used for the update of the container" >> $GITHUB_STEP_SUMMARY | |
echo "- \`${{ env.DATE }}\` -- The date and time on which the update for the container was ran" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
echo "The \`latest\` tag has been updated." >> $GITHUB_STEP_SUMMARY |