-
Notifications
You must be signed in to change notification settings - Fork 9
176 lines (154 loc) · 6.73 KB
/
release-docker-hub.yml
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Release to Docker Hub
# ower: FabioPinheiro
# updated: 2024/11/25
# How to test:
# > git tag v9.9.9
# > git tag --delete v9.9.9
# > act --artifact-server-path /tmp/artifacts -s GITHUB_TOKEN="$(gh auth token)" --var DOCKERHUB_FMGP_USERNAME=$DOCKERHUB_FMGP_USERNAME -s DOCKERHUB_FMGP_TOKEN=$DOCKERHUB_FMGP_TOKEN --var DOCKERHUB_IDENTUS_USERNAME=$DOCKERHUB_IDENTUS_USERNAME -s DOCKERHUB_IDENTUS_TOKEN=$DOCKERHUB_IDENTUS_TOKEN -j build-and-push-docker-images schedule
# > act --artifact-server-path /tmp/artifacts -s GITHUB_TOKEN="$(gh auth token)" --var DOCKERHUB_FMGP_USERNAME=$DOCKERHUB_FMGP_USERNAME -s DOCKERHUB_FMGP_TOKEN=$DOCKERHUB_FMGP_TOKEN --var DOCKERHUB_IDENTUS_USERNAME=$DOCKERHUB_IDENTUS_USERNAME -s DOCKERHUB_IDENTUS_TOKEN=$DOCKERHUB_IDENTUS_TOKEN --workflows '.github/workflows/release-docker-hub.yml' push
# > act --artifact-server-path /tmp/artifacts -s GITHUB_TOKEN="$(gh auth token)" \
# --var DOCKERHUB_FMGP_USERNAME=$DOCKERHUB_FMGP_USERNAME -s DOCKERHUB_FMGP_TOKEN=$DOCKERHUB_FMGP_TOKEN \
# --var DOCKERHUB_IDENTUS_USERNAME=$DOCKERHUB_IDENTUS_USERNAME -s DOCKERHUB_IDENTUS_TOKEN=$DOCKERHUB_IDENTUS_TOKEN \
# workflow_dispatch --workflows '.github/workflows/release-docker-hub.yml' --eventpath \
# <( jq -n '{ inputs: { DEPLOYMENT_BRANCH: "v1.0.0" } }' )
# How to push old images from another repo:
# > docker login docker.io -u fmgp -p $DOCKERHUB_FMGP_TOKEN
# > docker login docker.io -u identus -p $DOCKERHUB_IDENTUS_TOKEN
# > OLD_TAG=ghcr.io/hyperledger/identus-mediator:1.0.0; NEW_TAG=docker.io/identus/identus-mediator:1.0.0; docker buildx imagetools create --tag "$NEW_TAG" "$OLD_TAG"
concurrency:
group: release
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Run every day at midnight UTC
push:
tags:
- v*
branches:
- 'main'
permissions:
contents: read
jobs:
build-binaries:
if: ${{ !contains(github.event.head_commit.message, 'chore(release)') }}
runs-on: ubuntu-latest
env:
GITHUB_ACTOR: "hyperledger-bot"
GITHUB_ACTOR_EMAIL: "hyperledger-bot@hyperledger.org"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true
SBT_OPTS: -Xmx2G
steps:
- uses: actions/checkout@v4
- name: Setup Java and Scala
uses: olafurpg/setup-scala@v14
with:
java-version: zulu@1.11.0
- name: Cache sbt
uses: coursier/cache-action@v6.3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Setup Scala.JS
uses: japgolly/setup-scalajs@v1
- name: Build Binaries
env:
NODE_OPTIONS: --openssl-legacy-provider
run: sbt -J-Xmx5120m "docker:stage"
- name: Save build Directory
uses: actions/upload-artifact@v4
with:
name: docker-directory-artifact
path: ./mediator/target/docker/stage
build-and-push-docker-images:
name: Build and Push Docker images
runs-on: ubuntu-latest
needs: build-binaries
strategy:
fail-fast: false
matrix:
docker:
- # identus # This is a test account
registry: docker.io
repository: ${{vars.DOCKERHUB_IDENTUS_USERNAME}}
username: ${{vars.DOCKERHUB_IDENTUS_USERNAME}}
password_name: DOCKERHUB_IDENTUS_TOKEN
tags_noschedule: |
type=semver,pattern={{version}}
type=sha,format=long
type=edge,branch=main
type=raw,value=latest,enable=${{ !startsWith(github.ref, 'refs/tags/v') }}
tags_schedule: |
type=schedule,pattern=nightly,enable={{is_default_branch}}
- # fmgp # My presonal acount also for testing
registry: docker.io
repository: ${{vars.DOCKERHUB_FMGP_USERNAME}}
username: ${{vars.DOCKERHUB_FMGP_USERNAME}}
password_name: DOCKERHUB_FMGP_TOKEN
tags_noschedule: |
type=semver,pattern={{version}},enable={{is_default_branch}}
type=raw,value=latest,enable={{is_default_branch}}
tags_schedule: |
type=schedule,enable={{is_default_branch}}
steps:
- name: Set test variable
run: |
echo "META_CONFIG<<EOF" >> $GITHUB_ENV
if [ ${{ github.event_name }} == 'schedule' ]; then
echo "${{matrix.docker.tags_schedule}}" >> $GITHUB_ENV;
else
echo "${{matrix.docker.tags_noschedule}}" >> $GITHUB_ENV;
fi
echo "EOF" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.docker.registry }}/${{ matrix.docker.repository }}/identus-mediator
tags: "${{ env.META_CONFIG }}"
- name: JOB INFO
run: |
echo "##################"
echo "#### JOB INFO ####"
echo "##################"
echo "### github.event_name=${{github.event_name}} (Is this type 'schedule'""? ${{ github.event_name == 'schedule' }})"
echo "### matrix.docker.tags_schedule: ${{ matrix.docker.tags_schedule }}"
echo "### matrix.docker.tags_noschedule: ${{ matrix.docker.tags_noschedule }}"
echo "### env.META_CONFIG: ${{ env.META_CONFIG }}"
echo "### TAGS: ${{ steps.meta.outputs.tags == '' }}"
echo "${{ steps.meta.outputs.tags }}"
echo "### runner: ${{ toJSON(runner) }}"
echo "### github: ${{ toJSON(github) }}"
- name: Download docker-directory-artifact
uses: actions/download-artifact@v4
with:
name: docker-directory-artifact
path: docker-artifact
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
buildkitd-config-inline: |
[worker.oci]
max-parallelism = 1
platforms: linux/amd64,linux/arm64
- name: Login to the ${{ matrix.docker.registry }} Container Registry with ${{ matrix.docker.username }}
uses: docker/login-action@v3
with:
registry: ${{ matrix.docker.registry }}
username: ${{ matrix.docker.username }}
password: ${{ secrets[matrix.docker.password_name] }}
# TODO FIX These builds the image multiple times (matrix)
- name: Build and push identus-mediator Image
id: push
uses: docker/build-push-action@v6
with:
context: ./docker-artifact/
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
push: ${{ steps.meta.outputs.tags != '' }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}