Skip to content

Commit 9341226

Browse files
committed
chore: update Docker workflow configurations and actions
- Added Docker Buildx setup step to the docker-image workflow for improved build capabilities. - Updated Docker login, metadata, and build-push actions to their latest versions for enhanced functionality and security. - Changed the release workflow to use a local action for building Docker images, streamlining the process.
1 parent e21d586 commit 9341226

3 files changed

Lines changed: 178 additions & 4 deletions

File tree

.github/actions/release/action.yml

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: 'Release'
2+
description: 'Update version, publish release and push docker image'
3+
inputs:
4+
version_increment:
5+
description: 'La version a incrémenter (major, minor, patch)'
6+
required: true
7+
default: 'patch'
8+
9+
build_docker_image:
10+
description: "Construire l'image docker ?"
11+
required: true
12+
default: 'true'
13+
14+
latest:
15+
description: "Tagger l'image docker avec le tag 'latest' ?"
16+
required: true
17+
default: 'true'
18+
19+
repository:
20+
description: 'Repository to the project'
21+
required: true
22+
23+
username:
24+
description: 'Username to the project'
25+
required: true
26+
27+
password:
28+
description: 'Password to the project'
29+
required: true
30+
31+
github_token:
32+
description: 'Github token to the project'
33+
required: true
34+
35+
registry:
36+
description: 'Docker registry base url'
37+
default: 'ghcr.io'
38+
required: false
39+
40+
context:
41+
description: 'Docker context'
42+
default: '.'
43+
required: false
44+
45+
args:
46+
description: 'Docker build args'
47+
default: ''
48+
required: false
49+
50+
is_branch_protected:
51+
description: 'Push on a protected branch ? (required github_token)'
52+
default: false
53+
required: false
54+
55+
runs:
56+
using: 'composite'
57+
steps:
58+
- name: Checkout repository
59+
uses: actions/checkout@v4
60+
with:
61+
repository: ${{ inputs.repository }}
62+
63+
- name: Checkout code
64+
uses: actions/checkout@v4
65+
66+
- name: Set up Git
67+
shell: bash
68+
run: |
69+
git config user.email "github@action.com"
70+
git config user.name "Github Action"
71+
echo ${{ inputs.github_token }} > token.txt
72+
git config credential.helper "store --file=token.txt"
73+
74+
- name: Update version
75+
shell: bash
76+
run: |
77+
echo NEW_VERSION=$(yarn version --${{ inputs.version_increment }} --json | jq -r '.data | select(contains("New version")) | split(":")[1] | gsub(" ";"")') >> $GITHUB_ENV
78+
env:
79+
REF: ${{ github.ref }}
80+
81+
- name: Push to unprotected branch
82+
if: inputs.is_branch_protected == 'false'
83+
shell: bash
84+
run: |
85+
git push --follow-tags
86+
env:
87+
REF: ${{ github.ref }}
88+
89+
- name: Push to protected branch
90+
if: inputs.is_branch_protected == 'true'
91+
uses: CasperWA/push-protected@v2
92+
with:
93+
token: ${{ inputs.github_token }}
94+
branch: main
95+
unprotect_reviews: true
96+
tags: true
97+
98+
- name: Publish release
99+
uses: ncipollo/release-action@v1
100+
with:
101+
name: Release ${{ env.NEW_VERSION }}
102+
commit: ${{ env.REF }}
103+
draft: false
104+
prerelease: false
105+
generateReleaseNotes: true
106+
token: ${{ inputs.github_token }}
107+
makeLatest: ${{ inputs.latest }}
108+
tag: ${{ env.NEW_VERSION }}
109+
110+
- name: Get repo name
111+
shell: bash
112+
id: get_repo_name
113+
run: |
114+
echo "REPO_NAME=$(basename "${{ inputs.repository }}")" >> $GITHUB_ENV
115+
116+
- name: Get repo full name
117+
shell: bash
118+
id: get_repo_full_name
119+
run: |
120+
FULL_NAME=$(echo "${{ inputs.repository }}" | tr '[:upper:]' '[:lower:]')
121+
echo "REPO_FULL_NAME=$FULL_NAME" >> $GITHUB_ENV
122+
123+
- name: Get current date and time
124+
shell: bash
125+
id: get_current_date_time
126+
run: |
127+
echo "CURRENT_DATE_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
128+
129+
- name: Define tags
130+
shell: bash
131+
id: define_tags
132+
run: |
133+
if [ "${{ inputs.latest }}" = "true" ]; then
134+
echo "TAGS=ghcr.io/${{ env.REPO_FULL_NAME }}:${{ env.NEW_VERSION }},ghcr.io/${{ env.REPO_FULL_NAME }}:latest,ghcr.io/${{ env.REPO_FULL_NAME }}:unstable" >> $GITHUB_ENV
135+
else
136+
echo "TAGS=ghcr.io/${{ env.REPO_FULL_NAME }}:${{ env.NEW_VERSION }},ghcr.io/${{ env.REPO_FULL_NAME }}:unstable" >> $GITHUB_ENV
137+
fi
138+
env:
139+
NEW_VERSION: ${{ env.NEW_VERSION }}
140+
REPO_NAME: ${{ env.REPO_NAME }}
141+
REPO_FULL_NAME: ${{ env.REPO_FULL_NAME }}
142+
143+
- name: Set up QEMU
144+
if: ${{ inputs.build_docker_image == 'true' }}
145+
uses: docker/setup-qemu-action@v3
146+
147+
- name: Set up Docker Buildx
148+
if: ${{ inputs.build_docker_image == 'true' }}
149+
uses: docker/setup-buildx-action@v3.10.0
150+
151+
- name: Log in to the Container registry
152+
if: ${{ inputs.build_docker_image == 'true' }}
153+
uses: docker/login-action@v3
154+
with:
155+
registry: ${{ inputs.registry }}
156+
username: ${{ inputs.username }}
157+
password: ${{ inputs.password }}
158+
env:
159+
REGISTRY: ${{ inputs.registry }}
160+
161+
- name: Build and push Docker image
162+
if: ${{ inputs.build_docker_image == 'true' }}
163+
uses: docker/build-push-action@v6.18.0
164+
with:
165+
context: ${{ inputs.context }}
166+
push: true
167+
tags: ${{ env.TAGS }}
168+
build-args: ${{ inputs.args }}
169+
platforms: linux/amd64
170+
env:
171+
TAGS: ${{ env.TAGS }}

.github/workflows/docker-image.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,19 @@ jobs:
3939
- name: Run API unit tests
4040
run: yarn workspace @libertech-fr/sesame-orchestrator_api test
4141

42+
- name: Set up Docker Buildx
43+
uses: docker/setup-buildx-action@v3.10.0
44+
4245
- name: Log in to the Container registry
43-
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
46+
uses: docker/login-action@v3
4447
with:
4548
registry: ${{ env.REGISTRY }}
4649
username: ${{ github.actor }}
4750
password: ${{ secrets.GITHUB_TOKEN }}
4851

4952
- name: Extract metadata (tags, labels) for Docker
5053
id: meta
51-
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
54+
uses: docker/metadata-action@v5
5255
with:
5356
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
5457

@@ -59,7 +62,7 @@ jobs:
5962
echo "build_id=${{ github.sha }}" >> $GITHUB_OUTPUT
6063
6164
- name: Build and push Docker image
62-
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
65+
uses: docker/build-push-action@v6.18.0
6366
with:
6467
context: .
6568
push: true

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
run: yarn workspace @libertech-fr/sesame-orchestrator_api test
4848

4949
- name: Build docker
50-
uses: Libertech-FR/lt-actions/release@main
50+
uses: ./.github/actions/release
5151
with:
5252
version_increment: ${{ github.event.inputs.version_increment }}
5353
build_docker_image: ${{ github.event.inputs.build_docker_image }}

0 commit comments

Comments
 (0)