|
| 1 | +name: Publish Docker images |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + schedule: |
| 5 | + - cron: '0 0 * * 0' |
| 6 | +env: |
| 7 | + DOCKER_IMAGE_PREFIX: debian-perlbrew |
| 8 | +jobs: |
| 9 | + push_to_registries: |
| 10 | + name: Push Docker image to multiple registries |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + packages: write |
| 14 | + contents: read |
| 15 | + strategy: |
| 16 | + fail-fast: true |
| 17 | + max-parallel: 1 |
| 18 | + matrix: |
| 19 | + branch: ['bookworm', 'bullseye', 'buster'] |
| 20 | + folder: ['base', 'pyenv3', 'pyenv3-java'] |
| 21 | + steps: |
| 22 | + - |
| 23 | + name: Checkout |
| 24 | + uses: actions/checkout@v3 |
| 25 | + with: |
| 26 | + ref: ${{ matrix.branch }} |
| 27 | + - |
| 28 | + name: Set up QEMU |
| 29 | + uses: docker/setup-qemu-action@v2 |
| 30 | + - |
| 31 | + name: Set up Docker Buildx |
| 32 | + uses: docker/setup-buildx-action@v2 |
| 33 | + - name: Log in to Docker Hub |
| 34 | + uses: docker/login-action@v2 |
| 35 | + with: |
| 36 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 37 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 38 | + - name: Log in to GitHub Docker Registry |
| 39 | + uses: docker/login-action@v2 |
| 40 | + with: |
| 41 | + registry: ghcr.io |
| 42 | + username: ${{ github.actor }} |
| 43 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + - name: Sets env vars for Docker image |
| 45 | + run: | |
| 46 | + echo "DOCKER_IMAGE_TAG=${{env.DOCKER_IMAGE_PREFIX}}" >> $GITHUB_ENV |
| 47 | + if: ${{ matrix.folder == 'base' }} |
| 48 | + - name: Sets env vars for Docker image |
| 49 | + run: | |
| 50 | + echo "DOCKER_IMAGE_TAG=${{env.DOCKER_IMAGE_PREFIX}}-${{ matrix.folder }}" >> $GITHUB_ENV |
| 51 | + if: ${{ matrix.folder != 'base' }} |
| 52 | + - name: Sets env vars for Docker image |
| 53 | + run: | |
| 54 | + echo "DOCKER_IMAGE_BRANCH=${{ matrix.branch }}" >> $GITHUB_ENV |
| 55 | + - name: Push Docker |
| 56 | + uses: docker/build-push-action@v3 |
| 57 | + with: |
| 58 | + file: ./${{ matrix.folder }}/Dockerfile |
| 59 | + context: ./${{ matrix.folder }} |
| 60 | + platforms: linux/amd64,linux/arm64 |
| 61 | + push: true |
| 62 | + tags: | |
| 63 | + ${{ secrets.DOCKERHUB_ACCOUNT }}/${{env.DOCKER_IMAGE_TAG}}:${{ env.DOCKER_IMAGE_BRANCH }} |
| 64 | + ghcr.io/${{ github.repository_owner }}/${{env.DOCKER_IMAGE_TAG}}:${{ env.DOCKER_IMAGE_BRANCH }} |
| 65 | + if: ${{ matrix.branch != 'buster' }} # Non default branch |
| 66 | + - name: Push Docker |
| 67 | + uses: docker/build-push-action@v3 |
| 68 | + with: |
| 69 | + file: ./${{ matrix.folder }}/Dockerfile |
| 70 | + context: ./${{ matrix.folder }} |
| 71 | + platforms: linux/amd64,linux/arm64 |
| 72 | + push: true |
| 73 | + tags: | |
| 74 | + ${{ secrets.DOCKERHUB_ACCOUNT }}/${{env.DOCKER_IMAGE_TAG}}:${{ env.DOCKER_IMAGE_BRANCH }} |
| 75 | + ${{ secrets.DOCKERHUB_ACCOUNT }}/${{env.DOCKER_IMAGE_TAG}}:latest |
| 76 | + ghcr.io/${{ github.repository_owner }}/${{env.DOCKER_IMAGE_TAG}}:${{ env.DOCKER_IMAGE_BRANCH }} |
| 77 | + ghcr.io/${{ github.repository_owner }}/${{env.DOCKER_IMAGE_TAG}}:latest |
| 78 | + if: ${{ matrix.branch == 'buster' }} # Default branch |
0 commit comments