update README #19
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 Push Docker Image to GHCR | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*-*' # always in this format | |
| env: | |
| IMAGE_NAME: ghcr.io/${{ github.repository }} | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1️⃣ Checkout the exact code for the tag | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: ${{ github.ref }} | |
| # 2️⃣ Log in to GitHub Container Registry | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # 3️⃣ Set Docker tags | |
| - name: Set Docker tags | |
| run: | | |
| GIT_TAG="${GITHUB_REF#refs/tags/}" # e.g., v0.18.1-42 | |
| echo "IMMUTABLE_TAG=$GIT_TAG" >> $GITHUB_ENV | |
| echo "FLOATING_TAG=${GIT_TAG%-*}" >> $GITHUB_ENV | |
| # 4️⃣ Build Docker image with ARGs | |
| - name: Build Docker image | |
| run: | | |
| docker build \ | |
| --build-arg BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%S+00:00) \ | |
| --build-arg VERSION=$IMMUTABLE_TAG \ | |
| --build-arg COOKCLI_VERSION=$FLOATING_TAG \ | |
| -t $IMAGE_NAME:$IMMUTABLE_TAG . | |
| docker tag $IMAGE_NAME:$IMMUTABLE_TAG $IMAGE_NAME:$FLOATING_TAG | |
| # 5️⃣ Push Docker image to GHCR | |
| - name: Push Docker image | |
| run: | | |
| docker push $IMAGE_NAME:$IMMUTABLE_TAG | |
| docker push $IMAGE_NAME:$FLOATING_TAG |