Paywall2 (#147) #20
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: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
environment: docker-image-build | |
steps: | |
- name: Set Image Name | |
id: image_name | |
run: echo "IMAGE_NAME=thepew" >> $GITHUB_ENV | |
- name: Check Out Repository | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Azure Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io | |
username: ${{ secrets.AZURE_REGISTRY_USERNAME }} | |
password: ${{ secrets.AZURE_REGISTRY_PASSWORD }} | |
- name: Extract Version | |
id: version | |
run: | | |
MAJOR_MINOR=`cat VERSION` | |
SHORT_SHA=$(echo $GITHUB_SHA | cut -c 1-7) # Extracts first 7 characters of the commit SHA | |
echo "VERSION_TAG=${MAJOR_MINOR}-${SHORT_SHA}" >> $GITHUB_ENV | |
- name: Build and Push Docker Image | |
uses: docker/build-push-action@v5 | |
with: | |
build-args: | | |
RAILS_MASTER_KEY=${{ secrets.RAILS_MASTER_KEY }} | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: | | |
${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:${{ env.VERSION_TAG }} | |
${{ secrets.AZURE_REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:latest |