mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-07 05:46:37 +00:00
main branch will read go version from go.mod's go primitive, and only keep major and minor version, because we want the actions to use the lastest patch version automatically, even the go.mod specify version like 1.24.0. release branch can read the go version from go.mod file by setup-go action's own logic. Refactor the get Go version to reusable workflow. Signed-off-by: Xun Jiang <xun.jiang@broadcom.com>
64 lines
1.7 KiB
YAML
64 lines
1.7 KiB
YAML
name: Main CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
- 'release-**'
|
|
tags:
|
|
- '*'
|
|
|
|
jobs:
|
|
get-go-version:
|
|
uses: ./.github/workflows/get-go-version.yaml
|
|
with:
|
|
ref: ${ github.ref }
|
|
|
|
build:
|
|
name: Build
|
|
runs-on: ubuntu-latest
|
|
needs: get-go-version
|
|
steps:
|
|
- name: Check out the code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Set up Go version
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version: ${{ needs.get-go-version.outputs.version }}
|
|
|
|
- name: Set up QEMU
|
|
id: qemu
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: all
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
version: latest
|
|
- name: Build
|
|
run: |
|
|
make local
|
|
# Clean go cache to ease the build environment storage pressure.
|
|
go clean -modcache -cache
|
|
- name: Test
|
|
run: make test
|
|
- name: Upload test coverage
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: coverage.out
|
|
verbose: true
|
|
# Only try to publish the container image from the root repo; forks don't have permission to do so and will always get failures.
|
|
- name: Publish container image
|
|
if: github.repository == 'vmware-tanzu/velero'
|
|
run: |
|
|
sudo swapoff -a
|
|
sudo rm -f /mnt/swapfile
|
|
docker system prune -a --force
|
|
|
|
# Build and push Velero image to docker registry
|
|
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
|
|
./hack/docker-push.sh
|