2020-07-17 21:59:51 +00:00
|
|
|
name: Main CI
|
2020-05-27 23:34:12 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2020-07-17 21:59:51 +00:00
|
|
|
branches: [ main ]
|
2020-05-27 23:34:12 +00:00
|
|
|
tags:
|
|
|
|
- '*'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
|
|
|
build:
|
|
|
|
name: Build
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
|
2020-10-13 19:42:06 +00:00
|
|
|
- name: Set up Go
|
2020-05-27 23:34:12 +00:00
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
2021-12-06 12:10:20 +00:00
|
|
|
go-version: 1.17
|
2020-05-27 23:34:12 +00:00
|
|
|
id: go
|
|
|
|
|
|
|
|
- name: Check out code into the Go module directory
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
2020-11-30 19:19:07 +00:00
|
|
|
- name: Set up QEMU
|
|
|
|
id: qemu
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
with:
|
|
|
|
platforms: all
|
|
|
|
|
2020-08-04 18:40:05 +00:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
id: buildx
|
2020-11-30 19:19:07 +00:00
|
|
|
uses: docker/setup-buildx-action@v1
|
2020-08-04 18:40:05 +00:00
|
|
|
with:
|
2020-11-30 19:19:07 +00:00
|
|
|
version: latest
|
2020-08-04 18:40:05 +00:00
|
|
|
|
2020-05-27 23:34:12 +00:00
|
|
|
- name: Build
|
|
|
|
run: make local
|
|
|
|
|
|
|
|
- name: Test
|
|
|
|
run: make test
|
|
|
|
|
2020-09-22 22:04:50 +00:00
|
|
|
# Only try to publish the container image from the root repo; forks don't have permission to do so and will always get failures.
|
2020-05-27 23:34:12 +00:00
|
|
|
- name: Publish container image
|
2020-09-22 22:04:50 +00:00
|
|
|
if: github.repository == 'vmware-tanzu/velero'
|
2020-11-30 19:53:25 +00:00
|
|
|
run: |
|
|
|
|
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
./hack/docker-push.sh
|
2022-02-08 12:32:52 +00:00
|
|
|
|
2022-02-10 07:40:31 +00:00
|
|
|
# actions/checkout MUST come before auth
|
|
|
|
- uses: 'actions/checkout@v2'
|
|
|
|
|
|
|
|
# auth to GCP with OIDC token from GCP Workload Identity Provider. Output auth result to access token.
|
2022-02-08 12:32:52 +00:00
|
|
|
- id: 'auth'
|
|
|
|
name: 'Authenticate to Google Cloud'
|
|
|
|
uses: 'google-github-actions/auth@v0.6.0'
|
|
|
|
with:
|
2022-03-01 02:59:39 +00:00
|
|
|
credentials_json: '${{ secrets.GCR_SA_KEY }}'
|
2022-02-10 07:40:31 +00:00
|
|
|
token_format: 'access_token'
|
2022-02-08 12:32:52 +00:00
|
|
|
|
2022-02-10 07:40:31 +00:00
|
|
|
# Use access_token generated above to login gcr.io
|
|
|
|
- uses: 'docker/login-action@v1'
|
|
|
|
with:
|
|
|
|
registry: 'gcr.io' # or REGION.docker.pkg.dev
|
|
|
|
username: 'oauth2accesstoken'
|
|
|
|
password: '${{ steps.auth.outputs.access_token }}'
|
2022-02-08 12:32:52 +00:00
|
|
|
|
|
|
|
# Push image to GCR to facilitate some environments that have rate limitation to docker hub, e.g. vSphere.
|
|
|
|
- name: Publish container image to GCR
|
2022-02-10 07:40:31 +00:00
|
|
|
if: github.repository == 'vmware-tanzu/velero'
|
2022-02-08 12:32:52 +00:00
|
|
|
run: |
|
|
|
|
REGISTRY=gcr.io/velero-gcp ./hack/docker-push.sh
|