Skip to content

Commit

Permalink
Create separate build and publish workflows
Browse files Browse the repository at this point in the history
- Prevent failing CI for PRs bacause of missing permission to push
  images.
- Prevent image builds from users with sufficient permission to get
  published on PRs and branches other than master.

Signed-off-by: Han Verstraete (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
welteki authored and alexellis committed Jun 18, 2024
1 parent e6eff4a commit 3da4274
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 14 deletions.
22 changes: 8 additions & 14 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,23 @@ jobs:
id: get_repo_owner
run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" > $GITHUB_ENV

- name: Docker Login
run: >
echo ${{ secrets.GITHUB_TOKEN }} |
docker login ghcr.io --username
${{ env.REPO_OWNER }}
--password-stdin
- name: Publish multi-arch functions
- name: Pull templates
run: faas-cli template pull

- name: Build multi-arch functions
run: >
OWNER="${{ env.REPO_OWNER }}"
TAG="latest"
SERVER="ghcr.io"
faas-cli publish
--extra-tag ${{ github.sha }}
faas-cli build
--build-arg GO111MODULE=on
--platforms linux/arm/v7,linux/arm64,linux/amd64
-f stack.yml
- name: Publish amd64-only functions
- name: Build amd64-only functions
run: >
OWNER="${{ env.REPO_OWNER }}"
TAG="latest"
SERVER="ghcr.io"
faas-cli publish
--extra-tag ${{ github.sha }}
--platforms linux/amd64
faas-cli build
-f stack-amd64.yml
58 changes: 58 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: publish

on:
push:
branches:
- 'master'

jobs:
build:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

permissions:
packages: write
checks: write
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
with:
fetch-depth: 1
- name: Get faas-cli
run: curl -sLSf https://cli.openfaas.com | sudo sh
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Get Repo Owner
id: get_repo_owner
run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" > $GITHUB_ENV

- name: Docker Login
run: >
echo ${{ secrets.GITHUB_TOKEN }} |
docker login ghcr.io --username
${{ env.REPO_OWNER }}
--password-stdin
- name: Publish multi-arch functions
run: >
OWNER="${{ env.REPO_OWNER }}"
TAG="latest"
SERVER="ghcr.io"
faas-cli publish
--extra-tag ${{ github.sha }}
--build-arg GO111MODULE=on
--platforms linux/arm/v7,linux/arm64,linux/amd64
- name: Publish amd64-only functions
run: >
OWNER="${{ env.REPO_OWNER }}"
TAG="latest"
SERVER="ghcr.io"
faas-cli publish
--extra-tag ${{ github.sha }}
--platforms linux/amd64
-f stack-amd64.yml

0 comments on commit 3da4274

Please sign in to comment.