Skip to content

Commit

Permalink
enhance CI workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
abriko committed Apr 19, 2023
1 parent 50c1d7a commit 46e2db0
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/helm-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
push:
branches:
- master
paths:
- .github/workflows/helm-release.yaml
- "charts/**"

workflow_dispatch:

jobs:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ on:

jobs:

build_push:
uses: ./.github/workflows/image.yaml
secrets: inherit
permissions:
packages: write
contents: read

lint-test:
runs-on: ubuntu-latest
name: Helm Chart Lint
needs: build_push
env:
CT_CHART_DIRS: charts
CT_TARGET_BRANCH: $GITHUB_BASE_REF
Expand Down Expand Up @@ -45,6 +53,12 @@ jobs:
if: steps.list-changed.outputs.changed == 'true'
uses: helm/kind-action@v1.4.0

- name: Prepare test value
run: |
mkdir $CT_CHART_DIRS/certs/ci
echo "image:" > $CT_CHART_DIRS/certs/ci/image-values.yaml
echo " tag: ${{ needs.build_push.outputs.tag }}" >> $CT_CHART_DIRS/certs/ci/image-values.yaml
- name: Run chart-testing (install)
if: steps.list-changed.outputs.changed == 'true'
run: ct install --target-branch ${{ github.event.repository.default_branch }}
25 changes: 25 additions & 0 deletions .github/workflows/image-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Image Release

on:
push:
# Publish `master` as Docker `latest` image.
branches:
- master

# Publish `v1.2.3` tags as releases.
tags:
- v*

paths-ignore:
- "README.md"
- "charts/**"

workflow_dispatch:

jobs:
build_push:
uses: ./.github/workflows/image.yaml
secrets: inherit
permissions:
packages: write
contents: read
33 changes: 16 additions & 17 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
name: Build image

on:
push:
# Publish `master` as Docker `latest` image.
branches:
- master
- feature/*

# Publish `v1.2.3` tags as releases.
tags:
- v*

paths-ignore:
- "README.md"

# Run tests for any PRs.
pull_request:
workflow_call:
outputs:
image:
description: "Image uri"
value: ${{ jobs.push.outputs.image }}
tag:
description: "Image tag"
value: ${{ jobs.push.outputs.tag }}

env:
IMAGE_NAME: certs
Expand All @@ -28,6 +21,9 @@ jobs:
permissions:
packages: write
contents: read
outputs:
image: ${{ steps.push.outputs.image }}
tag: ${{ steps.push.outputs.tag }}

steps:
- uses: actions/checkout@v3
Expand All @@ -44,6 +40,7 @@ jobs:
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u $ --password-stdin

- name: Push image
id: push
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
Expand All @@ -54,8 +51,10 @@ jobs:
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
echo "image=$IMAGE_ID" >> $GITHUB_OUTPUT
echo "tag=$VERSION" >> $GITHUB_OUTPUT

0 comments on commit 46e2db0

Please sign in to comment.