|
31 | 31 | push: |
32 | 32 | branches: |
33 | 33 | - main |
34 | | - - api-logs |
35 | 34 | tags: [v*] |
36 | 35 |
|
37 | 36 | jobs: |
|
54 | 53 | env: |
55 | 54 | REGISTRY: ghcr.io |
56 | 55 | IMAGE_NAME: ${{ matrix.image_name }} |
57 | | - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} |
58 | 56 | permissions: |
59 | 57 | contents: read |
60 | 58 | packages: write |
|
71 | 69 | username: ${{ github.actor }} |
72 | 70 | password: ${{ secrets.GITHUB_TOKEN }} |
73 | 71 |
|
| 72 | + - name: Normalize branch name |
| 73 | + id: normalize_branch_name |
| 74 | + run: | |
| 75 | + BRANCH_NAME=$(echo "${{ github.ref_name }}" | tr '[:upper:]' '[:lower:]' | sed -r 's/[^a-z0-9]+/-/g' | sed -r 's/^-+|-+$//g') |
| 76 | + echo "normalized_branch_name=$BRANCH_NAME" >> "$GITHUB_OUTPUT" |
| 77 | +
|
74 | 78 | - name: Get current date |
75 | 79 | id: date |
76 | 80 | run: echo "date=$(date -u +'%Y-%m-%d_%H-%M-%S')" >> "$GITHUB_OUTPUT" |
|
84 | 88 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
85 | 89 | labels: | |
86 | 90 | org.opencontainers.image.description=${{ matrix.description }} |
87 | | - org.opencontainers.image.version=${{ env.BRANCH_NAME }}-${{ steps.date.outputs.date }}-${{ steps.commit_sha.outputs.sha_short }} |
| 91 | + org.opencontainers.image.version=${{ steps.normalize_branch_name.outputs.normalized_branch_name }}-${{ steps.date.outputs.date }}-${{ steps.commit_sha.outputs.sha_short }} |
88 | 92 | tags: | |
89 | 93 | type=raw,value=v1.0.0,enable=${{ github.ref_name == 'rebuild-v1.0.0' }} |
90 | 94 | type=raw,value=latest,enable=${{ github.ref_name == 'rebuild-v1.0.0' }} |
|
98 | 102 | run: echo "$DOCKER_METADATA_OUTPUT_JSON" | jq '.labels' > version_info.json |
99 | 103 | - name: Generate full image tag |
100 | 104 | id: full_tag |
101 | | - run: echo "full_tag=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ steps.date.outputs.date }}-${{ steps.commit_sha.outputs.sha_short }}" >> "$GITHUB_OUTPUT" |
| 105 | + run: echo "full_tag=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.normalize_branch_name.outputs.normalized_branch_name }}-${{ steps.date.outputs.date }}-${{ steps.commit_sha.outputs.sha_short }}" >> "$GITHUB_OUTPUT" |
102 | 106 | - name: Build Docker image |
103 | 107 | |
104 | 108 | with: |
@@ -156,4 +160,3 @@ jobs: |
156 | 160 | cache-to: type=gha,mode=max |
157 | 161 | - name: Adding markdown |
158 | 162 | run: echo 'TAGS ${{ steps.meta.outputs.tags }}' >> "$GITHUB_STEP_SUMMARY" |
159 | | - |
|
0 commit comments