| 1 |
name: Docker image build and push |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- 'master' |
| 7 |
schedule: |
| 8 |
- cron: '0 0 * * *' |
| 9 |
|
| 10 |
permissions: |
| 11 |
contents: read |
| 12 |
|
| 13 |
concurrency: |
| 14 |
group: docker-deployment |
| 15 |
cancel-in-progress: false |
| 16 |
|
| 17 |
jobs: |
| 18 |
docker: |
| 19 |
permissions: |
| 20 |
deployments: write |
| 21 |
packages: write |
| 22 |
if: github.repository == 'brainboxdotcc/DPP' |
| 23 |
strategy: |
| 24 |
fail-fast: false |
| 25 |
matrix: |
| 26 |
include: |
| 27 |
- platform: linux/amd64 |
| 28 |
runner: ubuntu-latest |
| 29 |
arch: amd64 |
| 30 |
- platform: linux/arm64 |
| 31 |
runner: ubuntu-24.04-arm |
| 32 |
arch: arm64 |
| 33 |
runs-on: ${{ matrix.runner }} |
| 34 |
steps: |
| 35 |
- name: Harden Runner |
| 36 |
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 |
| 37 |
with: |
| 38 |
egress-policy: audit |
| 39 |
|
| 40 |
- |
| 41 |
name: Set up Docker Buildx |
| 42 |
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c |
| 43 |
- |
| 44 |
name: Login to DockerHub |
| 45 |
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee |
| 46 |
with: |
| 47 |
username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 48 |
password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 49 |
- |
| 50 |
name: Build and push |
| 51 |
id: build |
| 52 |
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f |
| 53 |
with: |
| 54 |
platforms: ${{ matrix.platform }} |
| 55 |
outputs: type=image,name=brainboxdotcc/dpp,push-by-digest=true,name-canonical=true,push=true |
| 56 |
- |
| 57 |
name: Export digest |
| 58 |
run: | |
| 59 |
mkdir -p "${{ runner.temp }}/digests" |
| 60 |
digest="${{ steps.build.outputs.digest }}" |
| 61 |
touch "${{ runner.temp }}/digests/${digest#sha256:}" |
| 62 |
- |
| 63 |
name: Upload digest |
| 64 |
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a |
| 65 |
with: |
| 66 |
name: digests-${{ matrix.arch }} |
| 67 |
path: ${{ runner.temp }}/digests/* |
| 68 |
if-no-files-found: error |
| 69 |
retention-days: 1 |
| 70 |
|
| 71 |
manifest: |
| 72 |
permissions: |
| 73 |
deployments: write |
| 74 |
packages: write |
| 75 |
if: github.repository == 'brainboxdotcc/DPP' |
| 76 |
needs: docker |
| 77 |
runs-on: ubuntu-latest |
| 78 |
steps: |
| 79 |
- name: Harden Runner |
| 80 |
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 |
| 81 |
with: |
| 82 |
egress-policy: audit |
| 83 |
|
| 84 |
- |
| 85 |
name: Set up Docker Buildx |
| 86 |
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c |
| 87 |
- |
| 88 |
name: Download digests |
| 89 |
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c |
| 90 |
with: |
| 91 |
path: ${{ runner.temp }}/digests |
| 92 |
pattern: digests-* |
| 93 |
merge-multiple: true |
| 94 |
- |
| 95 |
name: Login to DockerHub |
| 96 |
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee |
| 97 |
with: |
| 98 |
username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 99 |
password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 100 |
- |
| 101 |
name: Login to GitHub Container Registry |
| 102 |
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee |
| 103 |
with: |
| 104 |
registry: ghcr.io |
| 105 |
username: ${{ github.repository_owner }} |
| 106 |
password: ${{ secrets.GITHUB_TOKEN }} |
| 107 |
- |
| 108 |
name: Create multi-platform image |
| 109 |
working-directory: ${{ runner.temp }}/digests |
| 110 |
run: | |
| 111 |
docker buildx imagetools create \ |
| 112 |
--tag brainboxdotcc/dpp:latest \ |
| 113 |
$(printf 'brainboxdotcc/dpp@sha256:%s ' *) |
| 114 |
- |
| 115 |
name: Push Image to multiple registries |
| 116 |
uses: akhilerm/tag-push-action@f35ff2cb99d407368b5c727adbcc14a2ed81d509 |
| 117 |
with: |
| 118 |
src: docker.io/brainboxdotcc/dpp:latest |
| 119 |
dst: | |
| 120 |
ghcr.io/brainboxdotcc/dpp:latest |