Update TF 1.8.2, TG 0.57.8 (#109) #847
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-Publish | |
on: | |
push: | |
branches: | |
release: | |
types: [released] | |
jobs: | |
build-publish: | |
name: "Atlantis-${{ matrix.ATLANTIS }} [ ${{ matrix.TF_TG }} ]" | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
ATLANTIS: | |
- 0.27.2 | |
TF_TG: | |
# Terraform 1.8.x | |
- 'TF-1.8.2 TG-0.57.8' | |
# Terraform 1.7.x | |
- 'TF-1.7.5 TG-0.57.8' | |
# Terraform 1.6.x | |
- 'TF-1.6.6 TG-0.57.8' | |
# Terraform 1.5.x | |
- 'TF-1.5.7 TG-0.57.8' | |
# Terraform 1.4.x | |
- 'TF-1.4.7 TG-0.57.8' | |
# Terraform 1.3.x | |
- 'TF-1.3.10 TG-0.57.8' | |
# Terraform 1.2.x | |
- 'TF-1.2.9 TG-0.57.8' | |
# Terraform 1.1.x | |
- 'TF-1.1.9 TG-0.57.8' | |
# Terraform 1.0.x | |
- 'TF-1.0.11 TG-0.57.8' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set Variables | |
id: vars | |
run: | | |
TERRAFORM="$( echo "${TF_TG}" | awk '{print $1}' | sed 's/TF-//g' )" | |
TERRAGRUNT="$( echo "${TF_TG}" | awk '{print $2}' | sed 's/TG-//g' )" | |
# Extract git tag or git branch | |
if echo "${GITHUB_REF}" | grep -q "refs/tags/"; then | |
SLUG="${GITHUB_REF/refs\/tags\//}" | |
fi | |
if echo "${GITHUB_REF}" | grep -q "refs/heads/"; then | |
SLUG="${GITHUB_REF/refs\/heads\//}" | |
if echo "${SLUG}" | grep -q '^dependabot\/'; then | |
SLUG="${SLUG/dependabot\/github_actions\/actions\//dependabot-}" | |
fi | |
fi | |
# Build Docker image tag | |
if [ "${SLUG}" = "master" ]; then | |
TAG="${ATLANTIS}-${TERRAFORM}-${TERRAGRUNT}" | |
else | |
TAG="${ATLANTIS}-${TERRAFORM}-${TERRAGRUNT}-${SLUG}" | |
fi | |
# Output for debugging | |
echo "ATLANTIS=${ATLANTIS}" | |
echo "TERRAFORM=${TERRAFORM}" | |
echo "TERRAGRUNT=${TERRAGRUNT}" | |
echo "SLUG=${SLUG}" | |
echo "TAG=${TAG}" | |
# Store GitHub Action env vars | |
echo "ATLANTIS=${ATLANTIS}" >> "${GITHUB_ENV}" | |
echo "TERRAFORM=${TERRAFORM}" >> "${GITHUB_ENV}" | |
echo "TERRAGRUNT=${TERRAGRUNT}" >> "${GITHUB_ENV}" | |
echo "TAG=${TAG}" >> "${GITHUB_ENV}" | |
env: | |
ATLANTIS: ${{ matrix.ATLANTIS }} | |
TF_TG: ${{ matrix.TF_TG }} | |
- name: Build | |
run: | | |
retry() { | |
for n in $(seq ${RETRIES}); do | |
echo "[${n}/${RETRIES}] ${*}"; | |
if eval "${*}"; then | |
echo "[SUCC] ${n}/${RETRIES}"; | |
return 0; | |
fi; | |
sleep 2; | |
echo "[FAIL] ${n}/${RETRIES}"; | |
done; | |
return 1; | |
} | |
retry make build ATLANTIS=${ATLANTIS} TERRAFORM=${TERRAFORM} TERRAGRUNT=${TERRAGRUNT} | |
env: | |
RETRIES: 20 | |
- name: Test | |
run: | | |
retry() { | |
for n in $(seq ${RETRIES}); do | |
echo "[${n}/${RETRIES}] ${*}"; | |
if eval "${*}"; then | |
echo "[SUCC] ${n}/${RETRIES}"; | |
return 0; | |
fi; | |
sleep 2; | |
echo "[FAIL] ${n}/${RETRIES}"; | |
done; | |
return 1; | |
} | |
retry make test ATLANTIS=${ATLANTIS} TERRAFORM=${TERRAFORM} TERRAGRUNT=${TERRAGRUNT} | |
env: | |
RETRIES: 20 | |
- name: Tag | |
run: | | |
make tag TAG=${TAG} | |
docker images | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
- name: Login | |
run: | | |
retry() { | |
for n in $(seq ${RETRIES}); do | |
echo "[${n}/${RETRIES}] ${*}"; | |
if eval "${*}"; then | |
echo "[SUCC] ${n}/${RETRIES}"; | |
return 0; | |
fi; | |
sleep 2; | |
echo "[FAIL] ${n}/${RETRIES}"; | |
done; | |
return 1; | |
} | |
retry make login DOCKER_USER=${{ secrets.DOCKER_USERNAME }} DOCKER_PASS=${{ secrets.DOCKER_PASSWORD }} | |
env: | |
RETRIES: 20 | |
# https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions | |
if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id | |
&& ( | |
(github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) | |
|| | |
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) | |
|| | |
(github.event_name == 'release' && github.event.action == 'released') | |
) | |
- name: Push | |
run: | | |
retry() { | |
for n in $(seq ${RETRIES}); do | |
echo "[${n}/${RETRIES}] ${*}"; | |
if eval "${*}"; then | |
echo "[SUCC] ${n}/${RETRIES}"; | |
return 0; | |
fi; | |
sleep 2; | |
echo "[FAIL] ${n}/${RETRIES}"; | |
done; | |
return 1; | |
} | |
retry make push TAG=${TAG} | |
env: | |
RETRIES: 20 | |
# https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions | |
if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id | |
&& ( | |
(github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) | |
|| | |
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) | |
|| | |
(github.event_name == 'release' && github.event.action == 'released') | |
) |