Skip to content

Commit 534ac3c

Browse files
committed
Publish CI images to Docker Hub and GHCR
1 parent c0c45f1 commit 534ac3c

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

.github/workflows/build.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ on:
66
- '**'
77
paths:
88
- 'src/**'
9+
- 'main.py'
910
- 'docker/**'
1011
- '.github/workflows/build.yml'
1112
pull_request:
1213
branches:
1314
- '**'
1415
paths:
1516
- 'src/**'
17+
- 'main.py'
1618
- 'docker/**'
1719
- '.github/workflows/build.yml'
1820
workflow_dispatch:
@@ -21,7 +23,7 @@ on:
2123
- '**'
2224

2325
permissions:
24-
contents: read
26+
contents: write
2527
packages: write
2628

2729
jobs:
@@ -86,12 +88,18 @@ jobs:
8688
uses: docker/setup-buildx-action@v3
8789

8890
- name: Log in to GitHub Container Registry
89-
uses: docker/login-action@v1
91+
uses: docker/login-action@v3
9092
with:
9193
registry: ghcr.io
9294
username: ${{ github.actor }}
9395
password: ${{ secrets.GITHUB_TOKEN }}
9496

97+
- name: Log in to Docker Hub
98+
uses: docker/login-action@v3
99+
with:
100+
username: ${{ secrets.DOCKERHUB_USERNAME }}
101+
password: ${{ secrets.DOCKERHUB_TOKEN }}
102+
95103
- name: Store short Commit ID in env variable
96104
id: vars
97105
run: |
@@ -126,20 +134,20 @@ jobs:
126134
127135
- name: Build, Tag, and Push Docker Image
128136
env:
129-
IMAGE_NAME: ghcr.io/${{ env.REPO_OWNER }}/decluttarr
137+
GHCR_IMAGE_NAME: ghcr.io/${{ env.REPO_OWNER }}/decluttarr
138+
DOCKERHUB_IMAGE_NAME: docker.io/${{ secrets.DOCKERHUB_USERNAME }}/decluttarr
130139
IMAGE_TAG: ${{ env.IMAGE_TAG }}
131140
run: |
132141
BRANCH_NAME="${{ github.ref_name }}"
133-
TAG_LATEST=""
142+
TAG_ARGS="-t ${GHCR_IMAGE_NAME}:${IMAGE_TAG} -t ${DOCKERHUB_IMAGE_NAME}:${IMAGE_TAG}"
134143
if [[ "$BRANCH_NAME" == "latest" ]]; then
135-
TAG_LATEST="-t $IMAGE_NAME:latest"
144+
TAG_ARGS="$TAG_ARGS -t ${GHCR_IMAGE_NAME}:latest -t ${DOCKERHUB_IMAGE_NAME}:latest"
136145
fi
137146
138147
docker buildx build \
139148
--platform linux/amd64,linux/arm64 -f docker/Dockerfile . \
140149
--progress plain \
141-
-t $IMAGE_NAME:$IMAGE_TAG \
142-
$TAG_LATEST \
150+
$TAG_ARGS \
143151
--label com.decluttarr.version=$IMAGE_TAG \
144152
--label com.decluttarr.commit=$SHORT_COMMIT_ID \
145153
--build-arg IMAGE_TAG=$IMAGE_TAG \

0 commit comments

Comments
 (0)