Skip to content

Commit e58cc1d

Browse files
feat: Update Docker login action and fix token handling (#78)
* added secrets to snapshot docker * minor fix * fix: update docker/login-action version to v3.6.0 * fix: correct token variable name and re-order login step in action.yml * mirnof xi * fix: correct Docker tags output for non-workflow dispatch events * fix: standardize token variable name to GIT_AUTH_TOKEN in action.yml
1 parent 525266f commit e58cc1d

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

payments-flow-docker-snapshot/action.yml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ inputs:
1616
maintainer=https://pagopa.it
1717
org.opencontainers.image.source=https://github.com/${{ github.repository }}
1818
19+
1920
runs:
2021
using: "composite"
2122
steps:
@@ -25,18 +26,13 @@ runs:
2526
shell: bash
2627
run: |
2728
if [ -n "${{ inputs.github_pat }}" ]; then
28-
echo "GITHUB_AUTH_TOKEN=${{ inputs.github_pat }}" >> $GITHUB_OUTPUT
29+
echo "ℹ️ Using personal GitHub PAT token"
30+
echo "GIT_AUTH_TOKEN=${{ inputs.github_pat }}" >> $GITHUB_OUTPUT
2931
else
30-
echo "GITHUB_AUTH_TOKEN=${{ github.token }}" >> $GITHUB_OUTPUT
32+
echo "ℹ️ Using default GitHub token"
33+
echo "GIT_AUTH_TOKEN=${{ github.token }}" >> $GITHUB_OUTPUT
3134
fi
3235
33-
- name: 🛃 Log in to the Github Container registry
34-
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
35-
with:
36-
registry: ghcr.io
37-
username: ${{ github.actor }}
38-
password: ${{ steps.set_token.outputs.GITHUB_AUTH_TOKEN }}
39-
4036
- name: 🤔 Set Docker tags
4137
id: set_docker_tags
4238
shell: bash
@@ -47,12 +43,21 @@ runs:
4743
echo "DOCKER_TAGS=ghcr.io/${{ github.repository }}:snapshot,ghcr.io/${{ github.repository }}:snapshot-${{ inputs.current_branch }}" >> $GITHUB_OUTPUT
4844
fi
4945
46+
- name: 🛃 Log in to the Github Container registry
47+
# https://github.com/docker/login-action/releases/tag/v3.6.0
48+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
49+
with:
50+
registry: ghcr.io
51+
username: ${{ github.actor }}
52+
password: ${{ steps.set_token.outputs.GIT_AUTH_TOKEN }}
53+
5054
- name: 🚀 Build and push Docker image
51-
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75
55+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
5256
with:
5357
context: .
5458
push: true
5559
tags: ${{ steps.set_docker_tags.outputs.DOCKER_TAGS }}
5660
labels: ${{ inputs.docker_labels }}
57-
build-args: |
58-
GITHUB_TOKEN=${{ steps.set_token.outputs.GITHUB_AUTH_TOKEN }}
61+
platforms: linux/amd64
62+
build-args: GIT_AUTH_TOKEN=${{ steps.set_token.outputs.GIT_AUTH_TOKEN }}
63+
secrets: GIT_AUTH_TOKEN=${{ steps.set_token.outputs.GIT_AUTH_TOKEN }}

payments-flow-release/action.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ runs:
4141
shell: bash
4242
run: |
4343
if [ -n "${{ inputs.github_pat }}" ]; then
44-
echo "GITHUB_AUTH_TOKEN=${{ inputs.github_pat }}" >> $GITHUB_OUTPUT
44+
echo "GIT_AUTH_TOKEN=${{ inputs.github_pat }}" >> $GITHUB_OUTPUT
4545
else
46-
echo "GITHUB_AUTH_TOKEN=${{ github.token }}" >> $GITHUB_OUTPUT
46+
echo "GIT_AUTH_TOKEN=${{ github.token }}" >> $GITHUB_OUTPUT
4747
fi
4848
4949
- name: 🚀 Release
5050
id: release
5151
uses: pagopa/eng-github-actions-iac-template/global/release-action@main
5252
with:
53-
github_token: ${{ steps.set_token.outputs.GITHUB_AUTH_TOKEN }}
53+
github_token: ${{ steps.set_token.outputs.GIT_AUTH_TOKEN }}
5454
tag_format: ${{ steps.set-tag-format.outputs.TAG_FORMAT }}
5555
branches: ${{ github.ref_name }}
5656

@@ -76,20 +76,23 @@ runs:
7676
- name: 🛃 Log in to the Github Container registry
7777
id: docker_login
7878
if: steps.release.outputs.new_release_published == 'true' && inputs.docker_build == 'true'
79-
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 #v3.2.0
79+
# https://github.com/docker/login-action/releases/tag/v3.6.0
80+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
8081
with:
8182
registry: ghcr.io
8283
username: ${{ github.actor }}
83-
password: ${{ steps.set_token.outputs.GITHUB_AUTH_TOKEN }}
84+
password: ${{ steps.set_token.outputs.GIT_AUTH_TOKEN }}
8485

8586
- name: 📦 Build and push Docker image with release version
8687
id: docker_build_push
8788
if: steps.release.outputs.new_release_published == 'true' && inputs.docker_build == 'true'
88-
uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c #v6.3.0
89+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
8990
with:
9091
context: .
9192
push: true
9293
tags: ${{ steps.set_docker_tags.outputs.DOCKER_TAGS }}
9394
labels: ${{ inputs.docker_labels }}
9495
build-args: |
95-
GITHUB_TOKEN=${{ steps.set_token.outputs.GITHUB_AUTH_TOKEN }}
96+
GIT_AUTH_TOKEN=${{ steps.set_token.outputs.GIT_AUTH_TOKEN }}
97+
secrets: |
98+
GIT_AUTH_TOKEN=${{ steps.set_token.outputs.GIT_AUTH_TOKEN }}

0 commit comments

Comments
 (0)