Updating build workflow with enhancements (#131)

* adding edge docker image tag for image based on main branch

* adding GHCR to container repos

* updating build apiVersion during build

* only doing build when certain paths are changed
This commit is contained in:
Tobias Lindberg
2021-12-31 10:44:59 +01:00
committed by GitHub
parent e7e3005e57
commit 1cac2e6806

View File

@@ -8,6 +8,11 @@ on:
- "bug-*"
tags:
- "v*"
paths:
- "src/**"
- "Dockerfile"
- "go.mod"
- "go.sum"
jobs:
build:
@@ -20,7 +25,13 @@ jobs:
id: docker_meta
uses: docker/metadata-action@v3.6.2
with:
images: tobiasehlert/teslamateapi
images: |
tobiasehlert/teslamateapi
ghcr.io/tobiasehlert/teslamateapi
tags: |
type=edge
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1.2.0
@@ -43,6 +54,23 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v1.12.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Configure build information
id: build_information
run: |
if [[ ${{ github.ref_type }} == "tag" ]]; then
echo "::set-output name=release_name::$( echo ${{ github.ref_name }} )"
else
echo "::set-output name=release_name::$( echo unknown )"
fi
- name: Build and push
uses: docker/build-push-action@v2.7.0
with:
@@ -55,4 +83,4 @@ jobs:
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
apiVersion=${{ github.event.release.tag_name }}
apiVersion=${{ steps.build_information.outputs.release_name }}