Build and Publish Docker Image #8
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Publish Docker Image | |
| on: | |
| push: | |
| tags: | |
| - 'release*' | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # - name: Set up Docker image name | |
| # id: vars | |
| # run: echo "IMAGE_NAME=ghcr.io/${{ github.repository }}" >> $GITHUB_ENV | |
| - name: Prepare Docker image name and tag | |
| run: | | |
| # Force lowercase for repository name | |
| REPO_LC=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]') | |
| # Use raw tag name (e.g., release_test_1.0), also force lowercase if needed | |
| IMAGE_TAG=$(echo "${GITHUB_REF_NAME}" | tr '[:upper:]' '[:lower:]') | |
| echo "IMAGE_NAME=ghcr.io/${REPO_LC}" >> $GITHUB_ENV | |
| echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV | |
| - name: Build Docker image | |
| run: docker build -t $IMAGE_NAME:$IMAGE_TAG . | |
| - name: Push Docker image | |
| run: docker push $IMAGE_NAME:$IMAGE_TAG |