Skip to content

Add terraform version (#32) #41

Add terraform version (#32)

Add terraform version (#32) #41

Workflow file for this run

name: Terraform Concourse Docker Image Build
on: [push, pull_request]
jobs:
build_matrix:
runs-on: ubuntu-latest
outputs:
matrix_json: ${{ steps.output_data.outputs.matrix_json }}
steps:
- name: Check out
uses: actions/checkout@v2
- name: Get Diff Action
uses: technote-space/[email protected]
with:
PATTERNS: |
terraform/*/Dockerfile
- name: Set output
if: env.GIT_DIFF_FILTERED
id: output_data
shell: bash
run: |
matrixJsonObject=$(echo $GIT_DIFF_FILTERED | jq --raw-input --raw-output 'gsub("'"'"'"; "") | split(" ") | map( { Dockerfile:.} ) | { include:. } | tostring')
echo "::set-output name=matrix_json::$matrixJsonObject"
echo $matrixJsonObject
echo $matrix_json
docker_image_build:
needs: build_matrix
if: needs.build_matrix.outputs.matrix_json
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.build_matrix.outputs.matrix_json) }}
steps:
- name: Check out
uses: actions/checkout@v2
- name: get version tag
id: versionTag
run: |
echo ${{ needs.build_matrix.outputs.matrix_json }}
echo ${{ fromJson(needs.build_matrix.outputs.matrix_json) }}
versionTag=$(head -1 ./${{ matrix.Dockerfile }} | grep -o '[0-9.]\+' )
echo "versionTag=$versionTag" >> $GITHUB_ENV
- name: Docker meta
id: docker_meta
uses: crazy-max/[email protected]
with:
images: teliaoss/concourse-terraform,ghcr.io/telia-oss/concourse-terraform
flavor: |
latest=false
tags: |
type=sha,enable=true,priority=500,prefix=sha-
type=edge,enable=false,priority=700,branch=$repo.default_branch
type=semver,enable=true,priority=900,pattern={{raw}},value=v${{ env.versionTag }}
labels: |
maintainer=Telia OSS
org.opencontainers.image.title=concourse-terraform
org.opencontainers.image.description=Alpine image with terraform and make installed (for use with Concourse).
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Dockerhub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.TELIAOSS_GHCR_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/[email protected]
with:
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
file: ./${{ matrix.Dockerfile }}