Update terraform.yml (#33) #44
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: Golang 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: | | |
golang/*/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" | |
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: | | |
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-golang,ghcr.io/telia-oss/concourse-golang | |
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=false,priority=900,pattern={{raw}},value=v${{ env.versionTag }} | |
type=raw,enable=true,priority=900,value=v${{ env.versionTag }} | |
labels: | | |
maintainer=Telia OSS | |
org.opencontainers.image.title=concourse-golang | |
org.opencontainers.image.description=Alpine golang toolbox for use in Concourse pipelines. | |
- 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 }} | |