Skip to content

ci: add build GitHub action #2

ci: add build GitHub action

ci: add build GitHub action #2

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
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: Login to Docker Hub
if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/') }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.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 }}