Skip to content

Commit

Permalink
Simplifiying branch name
Browse files Browse the repository at this point in the history
  • Loading branch information
pushyamig committed Oct 26, 2023
1 parent 1653602 commit 9656cb5
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ on:
required: true
default: '2023MMDD'
env:
IMAGE_TAG: latest
REPO_URL: ${{ github.repository }}

jobs:
Expand All @@ -32,22 +31,9 @@ jobs:
id: extract_branch
run: echo "BRANCH_NAME=$(basename ${{ github.ref }})" >> $GITHUB_ENV

- name: Set IMAGE_TAG based on event
run: |
if [ "$GITHUB_REF" == "refs/heads/master" ]; then
echo "Setting IMAGE_TAG to 'latest'"
echo "::set-env name=IMAGE_TAG::latest"
elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
echo "Setting IMAGE_TAG to '$GITHUB_REF'"
echo "::set-env name=IMAGE_TAG::${GITHUB_REF/refs\/tags\//}"
else
echo "Setting IMAGE_TAG to '$GITHUB_REF'"
echo "::set-env name=IMAGE_TAG::${GITHUB_REF/refs\/heads\//}"
fi
- name: build Docker image
run: |
docker build . --tag ghcr.io/${{ env.REPO_URL }}:${{ env.IMAGE_TAG }}
docker build . --tag ghcr.io/${{ env.REPO_URL }}:${BRANCH_NAME}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
Expand All @@ -58,7 +44,7 @@ jobs:

- name: Push Docker image to GitHub Container Registry
run: |
docker push ghcr.io/${{ env.REPO_URL }}:${{ env.IMAGE_TAG }}
docker push ghcr.io/${{ env.REPO_URL }}:${BRANCH_NAME}
release:
# Making sure that release only runs for tag pushes
Expand All @@ -73,7 +59,7 @@ jobs:
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 9656cb5

Please sign in to comment.