Use the product and image name for the chart, release, namespace, secrets, container and rendered file paths. The application package and local config paths keep their existing names. Bump the chart to 0.1.2 so the new chart name and paths are a distinct release. CI now publishes oci://gitea.tap-tap.win/taptap/charts/audiomanager.
120 lines
3.6 KiB
YAML
120 lines
3.6 KiB
YAML
name: CI
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- "v*"
|
|
pull_request:
|
|
|
|
env:
|
|
REGISTRY: gitea.tap-tap.win
|
|
IMAGE_NAME: taptap/audiomanager
|
|
CHART_REPO: taptap/charts
|
|
# Built by scripts/build-ci-image.sh from ci/Dockerfile. Bump the tag when
|
|
# ci/Dockerfile changes.
|
|
CI_IMAGE: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Test
|
|
run: gradle test --console=plain
|
|
- name: Smoke test
|
|
run: GRADLE=gradle ./scripts/smoke.sh
|
|
|
|
chart:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Lint and render the chart
|
|
run: |
|
|
helm lint charts/audiomanager
|
|
helm template audiomanager charts/audiomanager --set users.existingSecret=test > /dev/null
|
|
|
|
chart-push:
|
|
needs:
|
|
- chart
|
|
if: github.event_name == 'push'
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Log in to the registry
|
|
run: |
|
|
echo "${{ secrets.AUDIOMANAGER_REGISTRY_TOKEN }}" \
|
|
| helm registry login "$REGISTRY" \
|
|
--username "${{ gitea.actor }}" \
|
|
--password-stdin
|
|
- name: Package and push the chart
|
|
run: scripts/push-chart.sh
|
|
|
|
image:
|
|
needs:
|
|
- test
|
|
- chart
|
|
if: github.event_name == 'push'
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
env:
|
|
# A multi-stage build replaces / with the last stage's root filesystem,
|
|
# which deletes $HOME/.docker/config.json. Kaniko then has no credentials
|
|
# left for the push and gets an anonymous registry token (Gitea reports
|
|
# this as "401 reqPackageAccess"). /kaniko is preserved by kaniko, so
|
|
# keep the Docker credential store there for the whole job.
|
|
DOCKER_CONFIG: /kaniko/.docker
|
|
steps:
|
|
# No JavaScript actions in this job: kaniko unpacks the final stage's
|
|
# root filesystem over /, which removes the tools those actions need for
|
|
# their post steps (for example node from the CI image).
|
|
- name: Check out the source
|
|
run: |
|
|
set -euo pipefail
|
|
git init -q .
|
|
git remote add origin "$GITHUB_SERVER_URL/TapTap/AudioManager.git"
|
|
git fetch -q --depth=1 origin "$GITHUB_REF"
|
|
git checkout -q FETCH_HEAD
|
|
- name: Log in to the registry
|
|
run: |
|
|
mkdir -p "$DOCKER_CONFIG"
|
|
echo "${{ secrets.AUDIOMANAGER_REGISTRY_TOKEN }}" \
|
|
| docker login "$REGISTRY" \
|
|
--username "${{ gitea.actor }}" \
|
|
--password-stdin
|
|
- name: Build and push
|
|
run: |
|
|
set -euo pipefail
|
|
tags=("$REGISTRY/$IMAGE_NAME:sha-${GITHUB_SHA::7}")
|
|
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
|
tags+=("$REGISTRY/$IMAGE_NAME:${GITHUB_REF_NAME}")
|
|
else
|
|
tags+=("$REGISTRY/$IMAGE_NAME:latest")
|
|
fi
|
|
|
|
destinations=()
|
|
for tag in "${tags[@]}"; do
|
|
destinations+=(--destination "$tag")
|
|
done
|
|
|
|
kaniko-executor \
|
|
--context="dir://$PWD" \
|
|
--dockerfile="$PWD/Dockerfile" \
|
|
--snapshot-mode=redo \
|
|
"${destinations[@]}"
|