Make image compatible with Azure DevOps pipelines #57
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 | |
env: | |
IMAGE: terragrunt | |
on: | |
# Careful: Changing any of the triggers may | |
# lead to image pushed on unwanted branches, | |
# see the branch-based event usages below! | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
release: | |
types: [ published ] | |
jobs: | |
build: | |
name: Build Image | |
runs-on: ubuntu-latest | |
env: | |
TAG: canary | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set tag for non-main-branch builds | |
run: | | |
if [[ "${{ github.event_name }}" == "release" ]]; then | |
echo "TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | |
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
echo "TAG=pr${{github.event.number}}" >> $GITHUB_ENV | |
fi | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build | |
uses: docker/build-push-action@v3 | |
with: | |
load: true | |
tags: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.TAG }} | |
- name: Push | |
run: | | |
docker push ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.TAG }} | |
- name: Push latest | |
if: github.event_name == 'release' | |
run: | | |
docker tag ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.TAG }} \ | |
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:latest | |
docker push ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:latest | |
- name: Run version | |
run: | | |
docker run ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.TAG }} terraform -v | |
docker run ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.TAG }} terragrunt -v | |
- name: Inspect | |
run: | | |
docker image inspect ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.TAG }} |