diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6698596..d3d8724 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 }}