-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (57 loc) · 2.35 KB
/
publish-latest.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
name: Publish # Push latest version of the container to docker hub
on: # yamllint disable-line rule:truthy
push:
branches:
- "**"
env:
ORGANIZATION: "derekstraka"
IMAGE_NAME: "terraform-azure"
IMAGE_TAG: "latest"
jobs:
build_push_latest:
runs-on: ubuntu-22.04
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Retrieve latest suported versions
run: |
SUPPORTED_VERSIONS=$(cat ./supported_versions.yaml | python3 -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin)))')
echo "AZURE_CLI_VERSION=$(echo ${SUPPORTED_VERSIONS} | jq -r '.azure_cli_version | sort | .[-1]')" >> $GITHUB_ENV
echo "TERRAFORM_VERSION=$(echo ${SUPPORTED_VERSIONS} | jq -r '.terraform_version | sort | .[-1]')" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build docker image
uses: docker/build-push-action@v4
with:
context: .
load: true
tags: ${{ env.ORGANIZATION }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG}}
build-args: |
TERRAFORM_VERSION=${{ env.TERRAFORM_VERSION }}
AZURE_CLI_VERSION=${{ env.AZURE_CLI_VERSION }}
- name: Generate the tests from the templates
run: ./generate_tests.sh -t ${{ env.TERRAFORM_VERSION }} -a ${{ env.AZURE_CLI_VERSION }}
- name: run structure tests
uses: plexsystems/[email protected]
with:
image: ${{ env.ORGANIZATION }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG}}
config: tests/test.yaml
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
push: ${{ github.event.ref =='refs/heads/main' }}
tags: ${{ env.ORGANIZATION }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG}}
build-args: |
TERRAFORM_VERSION=${{ env.TERRAFORM_VERSION }}
AZURE_CLI_VERSION=${{ env.AZURE_CLI_VERSION }}