2020-07-17 21:59:51 +00:00
|
|
|
name: Main CI
|
2020-05-27 23:34:12 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2022-02-21 09:45:58 +00:00
|
|
|
branches:
|
|
|
|
- 'main'
|
|
|
|
- 'release-**'
|
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:
|
2022-09-07 23:39:31 +00:00
|
|
|
go-version: 1.18
|
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
|
|
|
|
|
2022-02-27 16:54:41 +00:00
|
|
|
- name: Upload test coverage
|
|
|
|
uses: codecov/codecov-action@v2
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
|
|
files: coverage.out
|
|
|
|
verbose: true
|
|
|
|
|
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-03-01 07:16:52 +00:00
|
|
|
# Use the JSON key in secret to login gcr.io
|
2022-02-10 07:40:31 +00:00
|
|
|
- uses: 'docker/login-action@v1'
|
|
|
|
with:
|
|
|
|
registry: 'gcr.io' # or REGION.docker.pkg.dev
|
2022-03-01 07:16:52 +00:00
|
|
|
username: '_json_key'
|
|
|
|
password: '${{ secrets.GCR_SA_KEY }}'
|
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
|