Skip to content

Commit

Permalink
build: change retagging to script
Browse files Browse the repository at this point in the history
  • Loading branch information
t03i committed Nov 9, 2024
1 parent b35299d commit f20cbb2
Showing 1 changed file with 17 additions and 25 deletions.
42 changes: 17 additions & 25 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,21 @@ jobs:
tag:
runs-on: ubuntu-latest
environment: production
outputs:
matrix: ${{ steps.meta-frontend.outputs.json }}
steps:
- name: Extract Frontend metadata
id: meta-frontend
uses: docker/metadata-action@v5
with:
images: ${{ inputs.image_name }}
tags: |
type=semver,pattern={{version}},value=${{ inputs.release_tag }}
type=semver,pattern={{major}}.{{minor}},value=${{ inputs.release_tag }}
type=semver,pattern={{major}},value=${{ inputs.release_tag }}
type=raw,value=latest
retag:
runs-on: ubuntu-latest
needs: tag
strategy:
matrix:
tags: ${{ fromJson(needs.tag.outputs.matrix.tags) }}

steps:
- name: Pull Image
run: docker pull ${{ inputs.image_name }}:${{ inputs.old_tag }}
- name: Retag Image
run: docker tag ${{ inputs.image_name }}:${{ inputs.old_tag }} ${{ matrix.tags }}
- name: Push Image
run: docker push ${{ matrix.tags }}
- name: Generate and apply tags
run: |
# Parse version components
version="${{ inputs.release_tag }}"
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
# Pull the source image
docker pull ${{ inputs.image_name }}:${{ inputs.old_tag }}
# Create and push each tag
for new_tag in "$version" "$major.$minor" "$major" "latest"; do
echo "Creating tag: $new_tag"
docker tag ${{ inputs.image_name }}:${{ inputs.old_tag }} ${{ inputs.image_name }}:$new_tag
docker push ${{ inputs.image_name }}:$new_tag
done

0 comments on commit f20cbb2

Please sign in to comment.