Skip to content

Commit 96f6e7f

Browse files
authored
Create main.yml
1 parent 6e4e395 commit 96f6e7f

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

.github/workflows/main.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: CI
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the main branch
8+
push:
9+
branches: [ main ]
10+
pull_request:
11+
branches: [ main ]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
# Then add the permissions for the GitHub token, so that the action can push to GHCR using its own temporary token.
17+
# This is more secure than generating your own personal access token which has access to your entire account, and may not expire
18+
permissions:
19+
actions: read
20+
checks: write
21+
contents: read
22+
packages: write
23+
24+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
25+
jobs:
26+
# This workflow contains a single job called "build"
27+
build:
28+
# The type of runner that the job will run on
29+
runs-on: ubuntu-latest
30+
31+
# Steps represent a sequence of tasks that will be executed as part of the job
32+
steps:
33+
34+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
35+
- uses: actions/checkout@v2
36+
with:
37+
fetch-depth: 1
38+
39+
# Install faas-cli
40+
- name: Get faas-cli
41+
run: curl -sLSf https://cli.openfaas.com | sudo sh
42+
43+
- name: Pull custom templates from stack.yml
44+
run: faas-cli template pull stack
45+
46+
# Set up Docker with buildx, so that it can cross-compile containers for different systems
47+
- name: Set up QEMU
48+
uses: docker/setup-qemu-action@v1
49+
50+
- name: Set up Docker Buildx
51+
uses: docker/setup-buildx-action@v1
52+
53+
- name: Get TAG
54+
id: get_tag
55+
run: echo ::set-output name=TAG::latest-dev
56+
57+
- name: Get Repo Owner
58+
id: get_repo_owner
59+
run: >
60+
echo ::set-output name=repo_owner::$(echo ${{ github.repository_owner }} |
61+
tr '[:upper:]' '[:lower:]')
62+
63+
# Log into the ghcr.io registry using the GitHub token attached to the GitHub Action
64+
- name: Docker Login
65+
run: >
66+
echo ${{secrets.GITHUB_TOKEN}} |
67+
docker login ghcr.io --username
68+
${{ steps.get_repo_owner.outputs.repo_owner }}
69+
--password-stdin
70+
71+
# Run faas-cli publish which builds and pushes a multi-arch image,
72+
# linux/amd64 - regular PCs and cloud
73+
# linux/arm/v7 - The 32-bit arm Raspberry Pi OS
74+
# linux/arm64 - 64-bit arm servers or Ubuntu running on Raspberry Pi
75+
- name: Publish functions
76+
run: >
77+
OWNER="${{ steps.get_repo_owner.outputs.repo_owner }}"
78+
TAG="latest"
79+
faas-cli publish
80+
--extra-tag ${{ github.sha }}
81+
--build-arg GO111MODULE=on
82+
--platforms linux/amd64,linux/arm/v7,linux/arm64
83+
84+
# log into remote gateway
85+
- name: Login
86+
run: >
87+
echo ${{secrets.OPENFAAS_PASSWORD}} |
88+
faas-cli login --gateway ${{secrets.OPENFAAS_URL}} --password-stdin
89+
90+
# deploy to remote gateway
91+
- name: Deploy
92+
run: >
93+
OWNER="${{ steps.get_repo_owner.outputs.repo_owner }}"
94+
TAG="${{ github.sha }}"
95+
faas-cli deploy --gateway ${{secrets.OPENFAAS_URL}}
96+

0 commit comments

Comments
 (0)