Skip to content

Commit 34a2690

Browse files
authored
Merge pull request #16 from WyriHaximusNet/push-docker-image-also-to-ghcr.io
Push Docker image also to ghcr.io
2 parents 0cd912f + cb17bf9 commit 34a2690

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

.github/workflows/craft-release.yaml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,24 @@ name: Create Release & And push Docker image
33
env:
44
DOCKER_IMAGE: wyrihaximusnet/kubernetes-redis-db-assignment-operator
55
DOCKER_BUILDKIT: 1
6+
DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING: '{"ghcr.io":"GHCR_TOKEN","docker.io":"HUB_PASSCODE"}'
67
MILESTONE: ${{ github.event.milestone.title }}
78
on:
89
milestone:
910
types:
1011
- closed
1112
jobs:
13+
registry-matrix:
14+
name: Extract registries from registry secret mapping
15+
runs-on: ubuntu-latest
16+
outputs:
17+
registry: ${{ steps.registry-matrix.outputs.registry }}
18+
steps:
19+
- uses: actions/checkout@v1
20+
- id: registry-matrix
21+
name: Extract registries from registry secret mapping
22+
run: |
23+
echo "::set-output name=registry::$(printenv DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING | jq -c 'keys')"
1224
generate-changelog:
1325
name: Generate Changelog
1426
runs-on: ubuntu-latest
@@ -58,15 +70,24 @@ jobs:
5870
draft: false
5971
prerelease: false
6072
tag:
73+
needs:
74+
- registry-matrix
6175
runs-on: 'ubuntu-latest'
76+
strategy:
77+
fail-fast: false
78+
matrix:
79+
registry: ${{ fromJson(needs.registry-matrix.outputs.registry) }}
6280
steps:
6381
- uses: actions/checkout@v2
64-
- run: docker build . -t "${DOCKER_IMAGE}:${{ env.MILESTONE }}"
82+
- run: docker build . -t "${{ matrix.registry }}/${DOCKER_IMAGE}:${{ env.MILESTONE }}"
6583
- name: Login to Docker Hub
6684
run: |
67-
echo "${{ secrets.HUB_PASSCODE }}" | \
68-
docker login \
69-
--username "${{ secrets.HUB_USERNAME }}" \
85+
echo "${{ env.DOCKER_PASSWORD }}" | \
86+
docker login ${{ matrix.registry }} \
87+
--username "${{ env.DOCKER_USER }}" \
7088
--password-stdin
89+
env:
90+
DOCKER_USER: ${{ secrets.HUB_USERNAME }}
91+
DOCKER_PASSWORD: ${{ secrets[fromJson(env.DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING)[matrix.registry]] }}
7192
- name: Push release
72-
run: docker push "${DOCKER_IMAGE}:${{ env.MILESTONE }}"
93+
run: docker push "${{ matrix.registry }}/${DOCKER_IMAGE}:${{ env.MILESTONE }}"

0 commit comments

Comments
 (0)