63
63
BRANCH_NAME : ${{ inputs.branch_name }}
64
64
run : |
65
65
set -x
66
- pretty_branch_name="$(echo -n "${BRANCH_NAME#refs/heads/}" | sed 's#/#-#g' | sed 's#_#-#g'| sed 's#\. #-#g' | tr '[:upper:]' '[:lower:]')"
67
- echo "pretty_branch_name=$pretty_branch_name" >> $ GITHUB_OUTPUT
66
+ pretty_branch_name="$(echo -n "${BRANCH_NAME#refs/heads/}" | sed -E 's#[/_\.-]+ #-#g' | tr '[:upper:]' '[:lower:]' | cut -c1-25 | sed -E 's#-$##g ')"
67
+ echo "pretty_branch_name=${ pretty_branch_name} " >> "${ GITHUB_OUTPUT}"
68
68
current_time="$(date +'%Y%m%d.%H%M%S')"
69
69
branch="-${pretty_branch_name}"
70
70
short_sha="$(git rev-parse --short HEAD)"
@@ -76,29 +76,24 @@ jobs:
76
76
echo "image_version=$version" >> $GITHUB_OUTPUT
77
77
78
78
- name : Set up Docker Buildx
79
- uses : docker/setup-buildx-action@v3.7.1
79
+ uses : docker/setup-buildx-action@v3.8.0
80
80
81
81
- name : Login to DockerHub
82
82
83
83
with :
84
84
username : ${{ vars.DOCKERHUB_USERNAME }}
85
85
password : ${{ secrets.DOCKERHUB_TOKEN }}
86
86
87
- - name : Calculate Docker tags
88
- id : calculate-docker-tags
89
- uses : actions/github-script@v7
90
- env :
91
- TAGS : " ${{ steps.version.outputs.image_version }},${{ steps.version.outputs.pretty_branch_name }}"
92
- IMAGE_NAME : ${{ env.IMAGE_NAME }}
87
+ - name : Extract Docker metadata
88
+ id : meta
89
+ uses : docker/metadata-action@v5
93
90
with :
94
- script : |
95
- const raw_tags_input = process.env.TAGS;
96
- const image_name = process.env.IMAGE_NAME;
97
-
98
- const tags = raw_tags_input.split(',').map(x => x.trim());
99
- const docker_tags = tags.map(x => `${image_name}:${x}`).join(',');
100
- console.log(docker_tags);
101
- core.setOutput("docker-tags", docker_tags);
91
+ images : ${{ env.IMAGE_NAME }}
92
+ labels : |
93
+ org.opencontainers.image.revision=${{ inputs.sha }}
94
+ tags : |
95
+ type=raw,value=${{ steps.version.outputs.image_version }}
96
+ type=raw,value=${{ steps.version.outputs.pretty_branch_name }}
102
97
103
98
- name : Push Docker image
104
99
@@ -107,7 +102,11 @@ jobs:
107
102
context : .
108
103
file : Dockerfile.app
109
104
push : ${{ steps.actor-membership.outputs.active }}
110
- tags : ${{ steps.calculate-docker-tags.outputs.docker-tags }}
105
+ platforms : linux/amd64,linux/arm64
106
+ sbom : true
107
+ provenance : true
108
+ tags : ${{ steps.meta.outputs.tags }}
109
+ labels : ${{ steps.meta.outputs.labels }}
111
110
cache-from : type=gha
112
111
cache-to : type=gha,mode=max
113
112
0 commit comments