Skip to content

ci: add build GitHub action #7

ci: add build GitHub action

ci: add build GitHub action #7

Workflow file for this run

name: build
on:
push:
branches:
- master
- v*
tags:
- v*
pull_request:
jobs:
build:
name: Build images
runs-on: ubuntu-latest
permissions:
id-token: write # for reading credential https://github.com/rancher-eio/read-vault-secrets
container:
image: rancher/dapper:v0.6.0
steps:
# Git is not in Dapper container image. Add it manually for dirty check.
- name: Add Git
run: apk add -U git
- name: Checkout code
uses: actions/checkout@v4
- name: Declare branch
run: |
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_ENV"
# 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
# Build binaries
- name: Run dapper ci
run: dapper ci
- name: Copy bin folder to package
run: |
cp -r ./bin/* ./package/
- name: Echo GitHub Repository
run: |
echo "${{ github.repository }}"
- name: "Read some 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: "Use those Secrets"
run: |
echo "${{ env.DOCKER_USERNAME }}
- name: Login to Docker Hub
if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/') }}
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
# rancher/terraform-provider-harvester image
- name: docker-publish
if: ${{ startsWith(github.ref, 'refs/heads/') }}
uses: docker/build-push-action@v5
with:
context: package/
push: true
platforms: linux/amd64,linux/arm64
tags: rancher/terraform-provider-harvester:${{ 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: package/
push: true
platforms: linux/amd64,linux/arm64
tags: rancher/terraform-provider-harvester:${{ github.ref_name }}
file: package/Dockerfile
build-args: |
VERSION=${{ github.ref_name }}