Skip to content

Commit

Permalink
Add .github/workflow/main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
jp39 committed Oct 19, 2024
1 parent 93c3a0e commit a7d12e8
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: CI

on:
push:
tags:
- "v*.*.*"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Check out repo
uses: actions/checkout@v2

- name: Get versions
id: get_versions
run: |
echo GO_VERSION=$(go mod edit -json | grep -Po '"Go":\s+"([0-9.]+)"' | sed -E 's/.+"([0-9.]+)"/\1/') >> $GITHUB_ENV
echo BUILD_VERSION=${GITHUB_REF#refs/tags/v} >> $GITHUB_ENV
echo CHART_VERSION=${GITHUB_REF#refs/tags/} >> $GITHUB_ENV
- 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 Docker buildx
uses: docker/setup-buildx-action@v1

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
target: image
push: true
tags: ghcr.io/jp39/zfs-provisioner:latest,ghcr.io/jp39/zfs-provisioner:${{ env.BUILD_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: ${{ env.BUILD_VERSION }}
message: "Update image tag to ${{ env.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: ${{ env.CHART_VERSION }}
message: "Update chart version to ${{ env.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 }}

0 comments on commit a7d12e8

Please sign in to comment.