Build and Push Docker Image #2
Workflow file for this run
This file contains 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 | |
on: | |
release: | |
types: [published] | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Check Out Repository | |
uses: actions/checkout@v2 | |
- name: Log in to GitHub Container Registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Build Docker image | |
run: | | |
REPO_LOWER=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') | |
TAG=$(echo ${{ github.ref_name }} | tr '/' '-') # Replace / with - | |
docker build . -t ghcr.io/$REPO_LOWER:$TAG -t ghcr.io/$REPO_LOWER:latest --no-cache --target prod | |
- name: Push Docker image to GitHub Registry | |
run: | | |
REPO_LOWER=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') | |
TAG=$(echo ${{ github.ref_name }} | tr '/' '-') # Replace / with - | |
docker push ghcr.io/$REPO_LOWER:$TAG | |
docker push ghcr.io/$REPO_LOWER:latest |