-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (109 loc) · 4.02 KB
/
Copy pathdocker-publish-release.yaml
File metadata and controls
113 lines (109 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Docker Publish Multi-Arch on Release
on:
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
sync-version:
name: Sync application.properties with release tag
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout main
uses: actions/checkout@v5
with:
ref: main
token: ${{ secrets.MAIN_PUSH_TOKEN }}
- name: Configure git as the maintainer
run: |
git config user.name "PianoNic"
git config user.email "79938743+PianoNic@users.noreply.github.com"
- name: Compare versions and open + merge sync PR if different
env:
GH_TOKEN: ${{ secrets.MAIN_PUSH_TOKEN }}
run: |
TAG_VERSION="${{ github.event.release.tag_name }}"
TAG_VERSION="${TAG_VERSION#v}"
FILE_VERSION=$(grep -oP '(?<=<version>)[^<]+' application.properties)
echo "Release tag version: $TAG_VERSION"
echo "File version: $FILE_VERSION"
if [ "$TAG_VERSION" = "$FILE_VERSION" ]; then
echo "Already in sync, nothing to do."
exit 0
fi
sed -i "s|<version>$FILE_VERSION</version>|<version>$TAG_VERSION</version>|" application.properties
BRANCH="release-sync/$TAG_VERSION"
git checkout -b "$BRANCH"
git add application.properties
git commit -m "Bumped application.properties to $TAG_VERSION for release"
git push origin "$BRANCH"
PR_URL=$(gh pr create \
--base main \
--head "$BRANCH" \
--title "Bumped application.properties to $TAG_VERSION for release" \
--body "Bumped application.properties to $TAG_VERSION for release" \
--label CI/CD)
gh pr merge "$PR_URL" --admin --squash --delete-branch
build-and-push-multiarch:
name: Build and Push Multi-Arch Docker Images
needs: sync-version
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout main
uses: actions/checkout@v5
with:
ref: main
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
continue-on-error: true
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/schulykeycloak
ghcr.io/schulydev/schulykeycloak
tags: |
type=semver,pattern={{version}},value=${{ github.event.release.tag_name }}
type=semver,pattern={{major}}.{{minor}},value=${{ github.event.release.tag_name }}
type=semver,pattern={{major}},value=${{ github.event.release.tag_name }}
type=raw,value=latest,enable=${{ !github.event.release.prerelease }}
- name: Build and push Multi-Arch Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=gha
type=registry,ref=ghcr.io/schulydev/schulykeycloak:buildcache
cache-to: |
type=gha,mode=max
type=registry,ref=ghcr.io/schulydev/schulykeycloak:buildcache,mode=max
build-args: |
BUILDKIT_INLINE_CACHE=1
provenance: false
sbom: false