Skip to content

Commit 8b9df4b

Browse files
authored
Merge pull request #29 from T0biii/patch-1
add github packages registry
2 parents 9de10a1 + 73e84ca commit 8b9df4b

File tree

1 file changed

+46
-4
lines changed

1 file changed

+46
-4
lines changed

.github/workflows/docker.yml

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
strategy:
3939
matrix: ${{fromJson(needs.buildmatrix.outputs.matrix)}}
4040
fail-fast: false
41+
permissions:
42+
contents: read
43+
packages: write
4144
steps:
4245
-
4346
name: Checkout
@@ -54,6 +57,48 @@ jobs:
5457
with:
5558
username: splitbrain
5659
password: ${{ secrets.DOCKERHUB_TOKEN }}
60+
-
61+
name: Login to GitHub Container Registry
62+
uses: docker/login-action@v3
63+
with:
64+
registry: ghcr.io
65+
username: ${{ github.actor }}
66+
password: ${{ secrets.GITHUB_TOKEN }}
67+
-
68+
name: Prepare Docker Tags
69+
id: docker_tags
70+
run: |
71+
# Initialize tag arrays
72+
TAGS=()
73+
74+
# DockerHub Tags
75+
if [[ "${{ matrix.release.type }}" == "master" ]]; then
76+
TAGS+=("dokuwiki/dokuwiki:master")
77+
else
78+
TAGS+=("dokuwiki/dokuwiki:${{ matrix.release.date }}")
79+
TAGS+=("dokuwiki/dokuwiki:${{ matrix.release.type }}")
80+
if [[ "${{ matrix.release.type }}" == "stable" ]]; then
81+
TAGS+=("dokuwiki/dokuwiki:latest")
82+
fi
83+
fi
84+
85+
# GitHub Packages Tags
86+
if [[ "${{ matrix.release.type }}" == "master" ]]; then
87+
TAGS+=("ghcr.io/dokuwiki/dokuwiki:master")
88+
else
89+
TAGS+=("ghcr.io/dokuwiki/dokuwiki:${{ matrix.release.date }}")
90+
TAGS+=("ghcr.io/dokuwiki/dokuwiki:${{ matrix.release.type }}")
91+
if [[ "${{ matrix.release.type }}" == "stable" ]]; then
92+
TAGS+=("ghcr.io/dokuwiki/dokuwiki:latest")
93+
fi
94+
fi
95+
96+
# Convert array to multiline string for GitHub Actions
97+
{
98+
echo "tags<<EOF"
99+
printf "%s\n" "${TAGS[@]}"
100+
echo "EOF"
101+
} >> $GITHUB_OUTPUT
57102
-
58103
name: Build and push
59104
uses: docker/build-push-action@v5
@@ -62,10 +107,7 @@ jobs:
62107
push: true
63108
cache-from: type=gha, scope=${{ github.workflow }}
64109
cache-to: type=gha, scope=${{ github.workflow }}
65-
tags: |
66-
${{ matrix.release.type == 'master' && ' ' || format('dokuwiki/dokuwiki:{0}', matrix.release.date) }}
67-
dokuwiki/dokuwiki:${{ matrix.release.type }}
68-
${{ matrix.release.type == 'stable' && 'dokuwiki/dokuwiki:latest' || '' }}
110+
tags: ${{ steps.docker_tags.outputs.tags }}
69111
build-args: |
70112
DOKUWIKI_VERSION=${{ matrix.release.type == 'master' && 'master' || matrix.release.date }}
71113

0 commit comments

Comments
 (0)