chore(workflow): add "Scan With Trivy and Upload Results to GitHub Se… #58
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
name: build | |
on: | |
push: | |
branches: | |
- master | |
- v* | |
tags: | |
- v* | |
pull_request: | |
jobs: | |
build: | |
name: Build Binaries | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: Checkout Codes | |
uses: actions/checkout@v4 | |
# Build binaries | |
- name: Run CI | |
run: make ci | |
# Run e2e test | |
- name: Run e2e Test | |
run: make e2e-test | |
# Upload binaries | |
- name: Upload Binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries_artifact | |
path: ./bin/* | |
build_push_image: | |
name: Build and Push Images | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
needs: build | |
if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/') }} | |
steps: | |
- name: Checkout Codes | |
uses: actions/checkout@v4 | |
- name: Download Binaries | |
uses: actions/download-artifact@v4 | |
with: | |
name: binaries_artifact | |
path: ./bin/ | |
- name: Add Executable Permission | |
run: | | |
chmod +x ./bin/* | |
- name: Copy bin Folder to package Folder | |
run: | | |
cp -r ./bin ./package/ | |
# For multi-platform support | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Read Secrets | |
uses: rancher-eio/read-vault-secrets@main | |
with: | |
secrets: | | |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ; | |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD | |
- name: Get Branch Name | |
run: | | |
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_ENV" | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKER_USERNAME }} | |
password: ${{ env.DOCKER_PASSWORD }} | |
# rancher/local-path-provisioner image | |
- name: docker-publish | |
if: ${{ startsWith(github.ref, 'refs/heads/') }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./ | |
push: true | |
platforms: linux/amd64,linux/arm64,linux/arm,linux/riscv64 | |
tags: rancher/local-path-provisioner:${{ env.branch }}-head | |
file: package/Dockerfile | |
- name: docker-publish-with-tag | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./ | |
push: true | |
platforms: linux/amd64,linux/arm64,linux/arm,linux/riscv64 | |
tags: rancher/local-path-provisioner:${{ github.ref_name }} | |
file: package/Dockerfile |