Skip to content

Commit d553776

Browse files
committed
Create separate build and publish workflows
- 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]>
1 parent 07cc915 commit d553776

File tree

2 files changed

+62
-12
lines changed

2 files changed

+62
-12
lines changed

.github/workflows/build.yaml

+4-12
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,21 @@ jobs:
3434
id: get_repo_owner
3535
run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" > $GITHUB_ENV
3636

37-
- name: Docker Login
38-
run: >
39-
echo ${{ secrets.GITHUB_TOKEN }} |
40-
docker login ghcr.io --username
41-
${{ env.REPO_OWNER }}
42-
--password-stdin
43-
- name: Publish multi-arch functions
37+
- name: Build multi-arch functions
4438
run: >
4539
OWNER="${{ env.REPO_OWNER }}"
4640
TAG="latest"
4741
SERVER="ghcr.io"
48-
faas-cli publish
49-
--extra-tag ${{ github.sha }}
42+
faas-cli build
5043
--build-arg GO111MODULE=on
5144
--platforms linux/arm/v7,linux/arm64,linux/amd64
5245
53-
- name: Publish amd64-only functions
46+
- name: Build amd64-only functions
5447
run: >
5548
OWNER="${{ env.REPO_OWNER }}"
5649
TAG="latest"
5750
SERVER="ghcr.io"
58-
faas-cli publish
59-
--extra-tag ${{ github.sha }}
51+
faas-cli build
6052
--platforms linux/amd64
6153
-f stack-amd64.yml
6254

.github/workflows/publish.yaml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: publish
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
8+
jobs:
9+
build:
10+
concurrency:
11+
group: ${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
packages: write
16+
checks: write
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@master
21+
with:
22+
fetch-depth: 1
23+
- name: Get faas-cli
24+
run: curl -sLSf https://cli.openfaas.com | sudo sh
25+
- name: Set up QEMU
26+
uses: docker/setup-qemu-action@v3
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
30+
- name: Get Repo Owner
31+
id: get_repo_owner
32+
run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" > $GITHUB_ENV
33+
34+
- name: Docker Login
35+
run: >
36+
echo ${{ secrets.GITHUB_TOKEN }} |
37+
docker login ghcr.io --username
38+
${{ env.REPO_OWNER }}
39+
--password-stdin
40+
- name: Publish multi-arch functions
41+
run: >
42+
OWNER="${{ env.REPO_OWNER }}"
43+
TAG="latest"
44+
SERVER="ghcr.io"
45+
faas-cli publish
46+
--extra-tag ${{ github.sha }}
47+
--build-arg GO111MODULE=on
48+
--platforms linux/arm/v7,linux/arm64,linux/amd64
49+
50+
- name: Publish amd64-only functions
51+
run: >
52+
OWNER="${{ env.REPO_OWNER }}"
53+
TAG="latest"
54+
SERVER="ghcr.io"
55+
faas-cli publish
56+
--extra-tag ${{ github.sha }}
57+
--platforms linux/amd64
58+
-f stack-amd64.yml

0 commit comments

Comments
 (0)