Skip to content

Use helper func for cronjob #213

Use helper func for cronjob

Use helper func for cronjob #213

Workflow file for this run

name: Publish Docker image and Helm chart
on:
push
jobs:
run_tests:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: '1.19'
- name: Check out the repo
uses: actions/checkout@v2
- name: Test
run: go test ./...
create_docker_container:
name: Push Docker image to Github Registry
if: ${{ github.ref_name == 'main'}}
needs: [run_tests]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Get the version tag from Chart.yaml's appVersion tag
- name: Get appVersion
id: get_appversion
uses: CumulusDS/[email protected]
with:
file: charts/cronitor-kubernetes/Chart.yaml
appVersion: appVersion
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/cronitorio/cronitor-kubernetes
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}},value=${{ steps.get_appversion.outputs.appVersion }}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Github Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push to Github Registry
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
publish_helm_chart:
name: Create and publish Helm chart to Github pages
needs: [create_docker_container]
runs-on: ubuntu-latest
if: ${{ github.ref_name == 'main' }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Configure git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0
- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"