Skip to content

Commit

Permalink
fix job env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominion5254 committed Jan 16, 2025
1 parent 92812ac commit 2192932
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
tags:
- v*
workflow_dispatch:
workflow_call:

jobs:
push-image:
Expand All @@ -20,25 +19,23 @@ jobs:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set IMAGE_ID
run: echo "IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME" | tr '[A-Z]' '[a-z]' >> $GITHUB_ENV
- name: Debug IMAGE_ID
- name: Set Variables
run: |
echo "IMAGE_ID: $IMAGE_ID"
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "master" ] && VERSION=latest
echo "IMAGE_ID=$IMAGE_ID" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
env:
IMAGE_ID: ${{ env.IMAGE_ID }}
VERSION: ${{ env.VERSION }}
- name: Build image
run: |
echo "Building Docker image with context '.' and tag $IMAGE_ID"
docker buildx build . --platform linux/amd64,linux/arm64 --tag $IMAGE_ID --label "runnumber=${GITHUB_RUN_ID}" --push
run: docker buildx build . --platform linux/amd64,linux/arm64 --tag $IMAGE_ID --label "runnumber=${GITHUB_RUN_ID}" --push
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
run: docker push $IMAGE_ID:$VERSION
- name: Clean up Docker images
run: docker image prune -f

0 comments on commit 2192932

Please sign in to comment.