|
| 1 | +name: mirror-hardened-images |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: "23 4 * * 1" |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + paths: |
| 11 | + - ".github/scripts/mirror-dhi-image.sh" |
| 12 | + - ".github/workflows/mirror-hardened-images.yml" |
| 13 | + - "ansible/site.yml" |
| 14 | + - "ansible/roles/idp_zitadel/defaults/main.yml" |
| 15 | + - "ansible/roles/oauth2_proxy/defaults/main.yml" |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + packages: write |
| 20 | + |
| 21 | +jobs: |
| 22 | + mirror: |
| 23 | + runs-on: ubuntu-24.04 |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + include: |
| 28 | + - name: oauth2-proxy |
| 29 | + source: dhi.io/oauth2-proxy:7.15.2-debian13@sha256:8f4e89762735e7ec7c3f1bbdd5da4dcd55358db8c3278bfbc2e46a7f86ab7d9e |
| 30 | + target: ghcr.io/terion-name/terrarium-dhi-oauth2-proxy:7.15.2-debian13 |
| 31 | + package: terrarium-dhi-oauth2-proxy |
| 32 | + digest: sha256:8f4e89762735e7ec7c3f1bbdd5da4dcd55358db8c3278bfbc2e46a7f86ab7d9e |
| 33 | + arches: amd64,arm64 |
| 34 | + - name: postgres |
| 35 | + source: dhi.io/postgres:17.9-alpine3.22-fips@sha256:ae0f0ac1f942ff7898bb217e599cc488b5c7a2611a0957daae44c00584a59714 |
| 36 | + target: ghcr.io/terion-name/terrarium-dhi-postgres:17.9-alpine3.22-fips |
| 37 | + package: terrarium-dhi-postgres |
| 38 | + digest: sha256:ae0f0ac1f942ff7898bb217e599cc488b5c7a2611a0957daae44c00584a59714 |
| 39 | + arches: amd64,arm64 |
| 40 | + env: |
| 41 | + REGISTRY_AUTH_FILE: ${{ runner.temp }}/containers-auth.json |
| 42 | + HAS_DOCKERHUB_CREDS: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }} |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + |
| 46 | + - name: Install mirror tooling |
| 47 | + run: | |
| 48 | + sudo apt-get update |
| 49 | + sudo apt-get install -y jq skopeo |
| 50 | +
|
| 51 | + - name: Report missing Docker Hardened Images credentials |
| 52 | + if: env.HAS_DOCKERHUB_CREDS != 'true' |
| 53 | + run: | |
| 54 | + echo "::warning::DOCKERHUB_USERNAME and DOCKERHUB_TOKEN secrets are required to mirror Docker Hardened Images." |
| 55 | + if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then |
| 56 | + exit 1 |
| 57 | + fi |
| 58 | +
|
| 59 | + - name: Assert Docker Hardened Images credentials are configured |
| 60 | + if: env.HAS_DOCKERHUB_CREDS == 'true' |
| 61 | + env: |
| 62 | + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} |
| 63 | + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} |
| 64 | + run: | |
| 65 | + test -n "${DOCKERHUB_USERNAME}" || { echo "DOCKERHUB_USERNAME secret is required" >&2; exit 1; } |
| 66 | + test -n "${DOCKERHUB_TOKEN}" || { echo "DOCKERHUB_TOKEN secret is required" >&2; exit 1; } |
| 67 | +
|
| 68 | + - name: Login to Docker Hardened Images |
| 69 | + if: env.HAS_DOCKERHUB_CREDS == 'true' |
| 70 | + env: |
| 71 | + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} |
| 72 | + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} |
| 73 | + run: skopeo login dhi.io --username "${DOCKERHUB_USERNAME}" --password-stdin <<<"${DOCKERHUB_TOKEN}" |
| 74 | + |
| 75 | + - name: Login to GHCR |
| 76 | + if: env.HAS_DOCKERHUB_CREDS == 'true' |
| 77 | + run: skopeo login ghcr.io --username "${GITHUB_ACTOR}" --password-stdin <<<"${{ secrets.GITHUB_TOKEN }}" |
| 78 | + |
| 79 | + - name: Mirror pinned image index |
| 80 | + if: env.HAS_DOCKERHUB_CREDS == 'true' |
| 81 | + run: >- |
| 82 | + .github/scripts/mirror-dhi-image.sh |
| 83 | + "${{ matrix.name }}" |
| 84 | + "${{ matrix.source }}" |
| 85 | + "${{ matrix.target }}" |
| 86 | + "${{ matrix.digest }}" |
| 87 | + "${{ matrix.arches }}" |
| 88 | +
|
| 89 | + - name: Make GHCR package public when permitted |
| 90 | + if: env.HAS_DOCKERHUB_CREDS == 'true' |
| 91 | + continue-on-error: true |
| 92 | + env: |
| 93 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + PACKAGE_NAME: ${{ matrix.package }} |
| 95 | + run: | |
| 96 | + gh api --method PATCH "/user/packages/container/${PACKAGE_NAME}/visibility" -f visibility=public || |
| 97 | + gh api --method PATCH "/orgs/${GITHUB_REPOSITORY_OWNER}/packages/container/${PACKAGE_NAME}/visibility" -f visibility=public |
0 commit comments