63 lines
2.1 KiB
YAML
63 lines
2.1 KiB
YAML
name: Validate, publish and promote pixelfed chart
|
|
on:
|
|
push:
|
|
pull_request:
|
|
jobs:
|
|
validate:
|
|
runs-on: linux_amd64
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Lint and render
|
|
run: ./scripts/test.sh
|
|
publish:
|
|
if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main'
|
|
needs: validate
|
|
runs-on: linux_amd64
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Derive immutable chart version
|
|
run: echo "CHART_VERSION=$(./scripts/chart-version.sh)" >> "$GITHUB_ENV"
|
|
- name: Package and upload
|
|
env:
|
|
PACKAGE_USERNAME: ${{ secrets.PACKAGE_USERNAME }}
|
|
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
|
|
run: |
|
|
set -euo pipefail
|
|
test -n "$PACKAGE_USERNAME" && test -n "$PACKAGE_TOKEN"
|
|
helm package chart --destination "$RUNNER_TEMP" --version "$CHART_VERSION"
|
|
curl --fail --silent --show-error --user "$PACKAGE_USERNAME:$PACKAGE_TOKEN" \
|
|
--request POST --upload-file "$RUNNER_TEMP/pixelfed-$CHART_VERSION.tgz" \
|
|
https://code.brunner.ninja/api/packages/feedc0de/helm/api/charts
|
|
- name: Confirm current main
|
|
env:
|
|
COMMIT_SHA: ${{ gitea.sha }}
|
|
run: |
|
|
git fetch --no-tags origin main
|
|
test "$(git rev-parse FETCH_HEAD)" = "$COMMIT_SHA"
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
repository: feedc0de/homelab-gitops
|
|
ref: main
|
|
token: ${{ secrets.GITOPS_TOKEN }}
|
|
path: homelab-gitops
|
|
- name: Promote exact chart
|
|
working-directory: homelab-gitops
|
|
run: |
|
|
set -euo pipefail
|
|
./scripts/update-chart-version.sh pixelfed "$CHART_VERSION"
|
|
git config user.name feedc0de
|
|
git config user.email feedc0de@users.noreply.code.brunner.ninja
|
|
git add bootstrap/pixelfed.yaml
|
|
if git diff --cached --quiet; then exit 0; fi
|
|
git commit -m "Deploy pixelfed chart $CHART_VERSION"
|
|
for attempt in 1 2 3; do
|
|
git push origin HEAD:main && exit 0
|
|
test "$attempt" = 3 && exit 1
|
|
git fetch origin main
|
|
git rebase origin/main
|
|
done
|