CI: Fix publish job CI

This commit is contained in:
Quentin McGaw
2021-01-23 16:58:46 +00:00
parent 3769092888
commit 937d09f1c3

View File

@@ -11,18 +11,6 @@ on:
- Dockerfile - Dockerfile
- go.mod - go.mod
- go.sum - go.sum
release:
types: [published]
paths:
- .github/workflows/build.yml
- cmd/**
- internal/**
- pkg/**
- .dockerignore
- .golangci.yml
- Dockerfile
- go.mod
- go.sum
jobs: jobs:
verify: verify:
@@ -60,8 +48,6 @@ jobs:
run: docker build . run: docker build .
publish: publish:
if: github.event_name == 'release' ||
github.event_name == 'push'
needs: [verify] needs: [verify]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -81,18 +67,18 @@ jobs:
EVENT_NAME: ${{ github.event_name }} EVENT_NAME: ${{ github.event_name }}
run: | run: |
BRANCH=${GITHUB_REF#refs/heads/} BRANCH=${GITHUB_REF#refs/heads/}
TAG=${GITHUB_REF#refs/tags/}
echo ::set-output name=commit::$(git rev-parse --short HEAD) echo ::set-output name=commit::$(git rev-parse --short HEAD)
echo ::set-output name=build_date::$(date -u +%Y-%m-%dT%H:%M:%SZ) echo ::set-output name=build_date::$(date -u +%Y-%m-%dT%H:%M:%SZ)
echo ::set-output name=version::${GITHUB_REF#refs/heads/} if [ "$TAG" != "$GITHUB_REF" ]; then
if [ "$EVENT_NAME" = "push" ] && [ "$BRANCH" != "main" ]; then echo ::set-output name=version::$TAG
echo ::set-output name=version::$BRANCH echo ::set-output name=platforms::linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7,linux/s390x,linux/ppc64le
echo ::set-output name=platforms::linux/amd64 elif [ "$BRANCH" = "master" ]; then
elif [ "$EVENT_NAME" = "push" ] && [ "$BRANCH" = "main" ]; then
echo ::set-output name=version::latest echo ::set-output name=version::latest
echo ::set-output name=platforms::linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7,linux/s390x,linux/ppc64le echo ::set-output name=platforms::linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7,linux/s390x,linux/ppc64le
else else
echo ::set-output name=version::${GITHUB_REF#refs/tags/} echo ::set-output name=version::$BRANCH
echo ::set-output name=platforms::linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7,linux/s390x,linux/ppc64le echo ::set-output name=platforms::linux/amd64
fi fi
- name: Build and push final image - name: Build and push final image
@@ -108,7 +94,7 @@ jobs:
qmcgaw/private-internet-access:${{ steps.vars.outputs.version }} qmcgaw/private-internet-access:${{ steps.vars.outputs.version }}
push: true push: true
- if: github.event_name == 'push' && github.event.ref == 'refs/heads/main' - if: github.event_name == 'push' && github.event.ref == 'refs/heads/master'
name: Microbadger hook name: Microbadger hook
run: curl -X POST https://hooks.microbadger.com/images/qmcgaw/gluetun/l-keGI7p4IhX4QuIDMFYKhsZ1L0= run: curl -X POST https://hooks.microbadger.com/images/qmcgaw/gluetun/l-keGI7p4IhX4QuIDMFYKhsZ1L0=
continue-on-error: true continue-on-error: true