Skip to content

Commit e67e0ec

Browse files
fix(payment actions): Support maven github registry and linked Docker build/push (#74)
* added github token for maven package * Updated payments release to manage github token on maven * updated documentation * updated documentation
1 parent f0a0640 commit e67e0ec

File tree

4 files changed

+53
-8
lines changed

4 files changed

+53
-8
lines changed

payments-flow-docker-snapshot/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and if runned manually, create a fake tag called `develop-snapshot` + the previo
99

1010
## how to use
1111

12+
- `github_pat`: allow to use your github pat, if not the repository default github token will be used
13+
14+
### Example
15+
1216
```yaml
1317
name: 📦 Flow Snapshot Docker
1418

@@ -37,6 +41,10 @@ on:
3741
required: false
3842
default: 'main'
3943

44+
permissions:
45+
packages: write
46+
contents: read
47+
4048
env:
4149
# branch choosed by workflow_dispatch or by push event
4250
CURRENT_BRANCH: ${{ github.event.inputs.branch || github.ref_name }}

payments-flow-docker-snapshot/action.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ inputs:
55
current_branch:
66
description: Branch used to launch the action
77
required: true
8+
github_pat:
9+
description: Personal GitHub token for packages
10+
required: false
11+
default: ''
812
docker_labels:
913
description: Labels for docker push
1014
required: false
@@ -15,17 +19,24 @@ inputs:
1519
runs:
1620
using: "composite"
1721
steps:
22+
# Set the appropriate token
23+
- name: 🔐 Set GitHub Token
24+
id: set_token
25+
shell: bash
26+
run: |
27+
if [ -n "${{ inputs.github_pat }}" ]; then
28+
echo "GITHUB_AUTH_TOKEN=${{ inputs.github_pat }}" >> $GITHUB_OUTPUT
29+
else
30+
echo "GITHUB_AUTH_TOKEN=${{ github.token }}" >> $GITHUB_OUTPUT
31+
fi
32+
1833
- name: 🛃 Log in to the Github Container registry
19-
# https://github.com/docker/login-action/releases/tag/v3.3.0
2034
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
2135
with:
2236
registry: ghcr.io
2337
username: ${{ github.actor }}
24-
password: ${{ github.token }}
38+
password: ${{ steps.set_token.outputs.GITHUB_AUTH_TOKEN }}
2539

26-
#
27-
# Docker
28-
#
2940
- name: 🤔 Set Docker tags
3041
id: set_docker_tags
3142
shell: bash
@@ -37,10 +48,11 @@ runs:
3748
fi
3849
3950
- name: 🚀 Build and push Docker image
40-
# https://github.com/docker/build-push-action/releases/tag/v6.9.0
4151
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75
4252
with:
4353
context: .
4454
push: true
4555
tags: ${{ steps.set_docker_tags.outputs.DOCKER_TAGS }}
4656
labels: ${{ inputs.docker_labels }}
57+
build-args: |
58+
GITHUB_TOKEN=${{ steps.set_token.outputs.GITHUB_AUTH_TOKEN }}

payments-flow-release/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Allows to make a release and build a docker image with the follow tags:
88

99
## how to use
1010

11+
- `github_pat`: allow to use your github pat, if not the repository default github token will be used
12+
13+
### Example
14+
1115
```yaml
1216
name: 🚀 Flow Release
1317

@@ -23,6 +27,10 @@ on:
2327
- '.**'
2428
workflow_dispatch:
2529

30+
permissions:
31+
packages: write
32+
contents: write
33+
2634
jobs:
2735

2836
checkout:

payments-flow-release/action.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ inputs:
55
current_branch:
66
description: Branch used to launch the action
77
required: true
8+
github_pat:
9+
description: Personal GitHub token for packages
10+
required: false
11+
default: ''
812
docker_build:
913
description: Docker build
1014
required: false
@@ -31,11 +35,22 @@ runs:
3135
echo "TAG_FORMAT=v\${version}" >> $GITHUB_OUTPUT
3236
fi
3337
38+
# Set the appropriate token
39+
- name: 🔐 Set GitHub Token
40+
id: set_token
41+
shell: bash
42+
run: |
43+
if [ -n "${{ inputs.github_pat }}" ]; then
44+
echo "GITHUB_AUTH_TOKEN=${{ inputs.github_pat }}" >> $GITHUB_OUTPUT
45+
else
46+
echo "GITHUB_AUTH_TOKEN=${{ github.token }}" >> $GITHUB_OUTPUT
47+
fi
48+
3449
- name: 🚀 Release
3550
id: release
3651
uses: pagopa/eng-github-actions-iac-template/global/release-action@main
3752
with:
38-
github_token: ${{ github.token }}
53+
github_token: ${{ steps.set_token.outputs.GITHUB_AUTH_TOKEN }}
3954
tag_format: ${{ steps.set-tag-format.outputs.TAG_FORMAT }}
4055
branches: ${{ github.ref_name }}
4156

@@ -65,7 +80,7 @@ runs:
6580
with:
6681
registry: ghcr.io
6782
username: ${{ github.actor }}
68-
password: ${{ github.token }}
83+
password: ${{ steps.set_token.outputs.GITHUB_AUTH_TOKEN }}
6984

7085
- name: 📦 Build and push Docker image with release version
7186
id: docker_build_push
@@ -76,3 +91,5 @@ runs:
7691
push: true
7792
tags: ${{ steps.set_docker_tags.outputs.DOCKER_TAGS }}
7893
labels: ${{ inputs.docker_labels }}
94+
build-args: |
95+
GITHUB_TOKEN=${{ steps.set_token.outputs.GITHUB_AUTH_TOKEN }}

0 commit comments

Comments
 (0)