Skip to content

Add .github/workflow/main.yml #11

Add .github/workflow/main.yml

Add .github/workflow/main.yml #11

Workflow file for this run

name: CI
on:
push:
tags:
- "v*.*.*"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
packages: write
steps:
- name: Check out repo
uses: actions/checkout@v2
- name: Set vars
id: vars
run: |
echo go_version=$(go mod edit -json | grep -Po '"Go":\s+"([0-9.]+)"' | sed -E 's/.+"([0-9.]+)"/\1/') >> $GITHUB_OUTPUT
echo build_version=${GITHUB_REF#refs/tags/v} >> $GITHUB_OUTPUT
echo chart_version=${GITHUB_REF#refs/tags/} >> $GITHUB_OUTPUT
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
platforms: linux/amd64,linux/arm64
target: image
push: true
tags: ghcr.io/jp39/zfs-provisioner:latest,ghcr.io/jp39/zfs-provisioner:${{ steps.vars.outputs.build_version }}
build-args: |
GO_VERSION=${{ steps.vars.outputs.go_version }}
- name: Update Helm image tag
id: update_image
uses: fjogeleit/yaml-update-action@master
with:
valueFile: "charts/zfs-provisioner/values.yaml"
propertyPath: "image.tag"
value: ${{ steps.vars.outputs.build_version }}
message: "Update image tag to ${{ steps.vars.outputs.build_version }}"
token: ${{ secrets.GITHUB_TOKEN }}
branch: main
- name: Configure Git
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Update Helm chart version
uses: fjogeleit/yaml-update-action@master
with:
valueFile: "charts/zfs-provisioner/Chart.yaml"
propertyPath: "version"
value: ${{ steps.vars.outputs.chart_version }}
message: "Update chart version to ${{ steps.vars.outputs.chart_version }}"
token: ${{ secrets.GITHUB_TOKEN }}
updateFile: true
branch: main
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0
- name: Run chart-releaser
uses: helm/[email protected]
with:
charts_dir: deploy
env:
CR_RELEASE_NAME_TEMPLATE: "{{ .Version }}"
CR_TOKEN: ${{ secrets.GITHUB_TOKEN }}