Skip to content

Commit 3da4274

Browse files
weltekialexellis
authored andcommitted
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 e6eff4a commit 3da4274

File tree

2 files changed

+66
-14
lines changed

2 files changed

+66
-14
lines changed

.github/workflows/build.yaml

+8-14
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,23 @@ 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: Pull templates
38+
run: faas-cli template pull
39+
40+
- name: Build multi-arch functions
4441
run: >
4542
OWNER="${{ env.REPO_OWNER }}"
4643
TAG="latest"
4744
SERVER="ghcr.io"
48-
faas-cli publish
49-
--extra-tag ${{ github.sha }}
45+
faas-cli build
5046
--build-arg GO111MODULE=on
51-
--platforms linux/arm/v7,linux/arm64,linux/amd64
47+
-f stack.yml
5248
53-
- name: Publish amd64-only functions
49+
- name: Build amd64-only functions
5450
run: >
5551
OWNER="${{ env.REPO_OWNER }}"
5652
TAG="latest"
5753
SERVER="ghcr.io"
58-
faas-cli publish
59-
--extra-tag ${{ github.sha }}
60-
--platforms linux/amd64
54+
faas-cli build
6155
-f stack-amd64.yml
6256

.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)