Skip to content

Commit

Permalink
use separate jobs for go-releaser and ghcr push, fix permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
tillkuhn committed Aug 29, 2023
1 parent 2317d46 commit ade88da
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: goreleaser

env:
REGISTRY: ghcr.io # default is docker.io
IMAGE_NAME: ${{ github.repository }}

on:
push:
tags:
Expand All @@ -12,12 +8,12 @@ on:
branches:
- pal-goes-ghcr

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') # todo remove, currently disabled for branch push
permissions:
contents: write # for go-releaser binaries
steps:
-
name: Checkout
Expand All @@ -34,23 +30,32 @@ jobs:
echo "VAULTPAL_VERSION=${GITHUB_REF#refs/*/}" >> "$GITHUB_ENV"
-
name: Run GoReleaser
if: startsWith(github.ref, 'refs/tags/') # todo remove, currently disabled for branch push
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

ghcrpush:
runs-on: ubuntu-latest
permissions:
packages: write # for container registry
env:
REGISTRY: ghcr.io # default is docker.io
IMAGE_NAME: ${{ github.repository }}
steps:
-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
name: Checkout
uses: actions/checkout@v3
with:
registry: ${{ env.REGISTRY }}
# You can use the ${{ github.actor }} context to automatically use the username of the user that triggered the workflow run.
username: ${{ github.actor }}
# You can use the automatically-generated GITHUB_TOKEN secret for the password
password: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
-
name: Set Variables used in build-args for docker build
run: |
echo "VAULTPAL_COMMIT=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV
echo "VAULTPAL_VERSION=${GITHUB_REF#refs/*/}" >> "$GITHUB_ENV"
-
name: Extract metadata (tags, labels) for Docker
id: meta
Expand All @@ -60,6 +65,15 @@ jobs:
-
name: Set up Docker Buildx for Multiple platform builds
uses: docker/[email protected]
-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
# You can use the ${{ github.actor }} context to automatically use the username of the user that triggered the workflow run.
username: ${{ github.actor }}
# You can use the automatically-generated GITHUB_TOKEN secret for the password
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push Docker image
uses: docker/[email protected]
Expand Down

0 comments on commit ade88da

Please sign in to comment.