Files
feedc0de 93c719b4c9
Validate, publish and promote visual-studio-code / validate (push) Successful in 25s
Validate, publish and promote visual-studio-code / publish (push) Failing after 24s
Add maintained visual-studio-code Helm chart
2026-10-18 18:57:35 +02:00

87 lines
2.8 KiB
YAML

name: Validate, publish and promote visual-studio-code
on:
push:
branches: [main]
pull_request:
env:
HELM_VERSION: v4.2.2
CHART_NAME: visual-studio-code
GITOPS_REPOSITORY: feedc0de/homelab-gitops
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: azure/setup-helm@v4
with:
version: ${{ env.HELM_VERSION }}
- run: ./test.sh
publish:
if: gitea.ref == 'refs/heads/main'
needs: validate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: azure/setup-helm@v4
with:
version: ${{ env.HELM_VERSION }}
- name: Publish chart
env:
PACKAGE_USERNAME: ${{ secrets.PACKAGE_USERNAME }}
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
run: |
set -euo pipefail
CHART_VERSION=$(./scripts/chart-version.sh)
install -d dist
helm package "chart/${CHART_NAME}" --destination dist --version "${CHART_VERSION}"
curl --fail-with-body \
--user "${PACKAGE_USERNAME}:${PACKAGE_TOKEN}" \
--request POST \
--upload-file "dist/${CHART_NAME}-${CHART_VERSION}.tgz" \
https://code.brunner.ninja/api/packages/feedc0de/helm/api/charts
printf 'CHART_VERSION=%s\n' "${CHART_VERSION}" >> "${GITHUB_ENV}"
- name: Check that this is still current main
id: current-main
env:
COMMIT_SHA: ${{ gitea.sha }}
run: |
git fetch --no-tags origin main
if [ "$(git rev-parse FETCH_HEAD)" = "${COMMIT_SHA}" ]; then
echo 'promote=true' >> "${GITEA_OUTPUT}"
else
echo 'promote=false' >> "${GITEA_OUTPUT}"
fi
- name: Check out GitOps
if: steps.current-main.outputs.promote == 'true'
uses: actions/checkout@v4
with:
repository: ${{ env.GITOPS_REPOSITORY }}
ref: main
token: ${{ secrets.GITOPS_TOKEN }}
path: homelab-gitops
- name: Promote exact chart version
if: steps.current-main.outputs.promote == 'true'
working-directory: homelab-gitops
run: |
set -euo pipefail
./scripts/update-chart-version.sh "${CHART_NAME}" "${CHART_VERSION}"
git config user.name feedc0de
git config user.email feedc0de@users.noreply.code.brunner.ninja
git add "bootstrap/${CHART_NAME}.yaml"
if git diff --cached --quiet; then exit 0; fi
git commit -m "Deploy ${CHART_NAME} chart ${CHART_VERSION}"
for attempt in 1 2 3; do
if git push origin HEAD:main; then exit 0; fi
test "${attempt}" != 3
git fetch origin main
git rebase origin/main
done