-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add ci workflow with build and test * add job for build and pushing images * fix dependency name * specify exact version for setup-pack action * remove line escapes for pack command * correct indentation on pack command * build once and tag and push separately * push all tags at once (excluding :latest) * ignore generated credentials from google-github-actions/auth * run on all pull requests * run in parallel * upgrade actions/setup-go to v5 due to deprecation of node 16 * set up go after checking out the code
- Loading branch information
1 parent
ea5a91b
commit 0902b47
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
|
||
env: | ||
GO_VERSION: ^1.21.5 | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build_and_test: | ||
name: Build and test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Test | ||
run: go test -v ./... | ||
|
||
package: | ||
name: Build and push image | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Pack | ||
uses: buildpacks/github-actions/[email protected] | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata for images | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=schedule | ||
type=ref,event=branch | ||
type=ref,event=tag | ||
type=ref,event=pr | ||
type=sha | ||
type=sha,format=long | ||
- name: Build images | ||
run: | | ||
pack build ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} \ | ||
--builder gcr.io/buildpacks/builder:v1 \ | ||
--env GOOGLE_FUNCTION_SIGNATURE_TYPE=http \ | ||
--env GOOGLE_FUNCTION_TARGET=ModProxy | ||
- name: Tag and push images | ||
run: | | ||
echo "${{ steps.meta.outputs.tags }}" | while read tag | ||
do | ||
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} $tag | ||
done | ||
docker rmi ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} --all-tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,6 @@ | |
|
||
# Go workspace file | ||
go.work | ||
|
||
# Ignore generated credentials from google-github-actions/auth | ||
gha-creds-*.json |