allow extending flux runtime ui beyond flux to create gitops runtime #569
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Helm chart | |
on: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- 'charts/**' | |
pull_request: | |
branches: | |
- 'main' | |
paths: | |
- 'charts/**' | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
CHART_LOCATION: weaveworks/charts | |
permissions: | |
contents: read # for actions/checkout to fetch code | |
jobs: | |
helm-new-version: | |
runs-on: ubuntu-latest | |
outputs: | |
old-version: ${{ steps.old-version.outputs.version }} | |
new-version: ${{ steps.new-version.outputs.version }} | |
steps: | |
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
with: | |
fetch-depth: 0 | |
- name: Find new version | |
id: new-version | |
run: | | |
NEW_VERSION=$(yq e '.version' charts/gitops-server/Chart.yaml) | |
echo "::set-output name=version::$NEW_VERSION" | |
- name: Find old version | |
id: old-version | |
run: | | |
git checkout ${{ github.event.pull_request.base.sha || github.event.before }} | |
OLD_VERSION=$(yq e '.version' charts/gitops-server/Chart.yaml) | |
echo "::set-output name=version::$OLD_VERSION" | |
helm-will-release: | |
runs-on: ubuntu-latest | |
needs: helm-new-version | |
if: github.event_name == 'pull_request' && needs.helm-new-version.outputs.old-version != needs.helm-new-version.outputs.new-version | |
steps: | |
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
with: | |
fetch-depth: 0 | |
- name: Find out if there's more changes to release | |
id: extra | |
run: | | |
last_revision=$(git blame ${{ github.event.pull_request.base.sha }} -L '/^version: [0-9.]\+$/,+1' charts/gitops-server/Chart.yaml | awk '{print $1}') | |
set +e | |
git log --exit-code $last_revision...${{ github.event.pull_request.base.sha }} charts/gitops-server | |
unreleased_commits=$? | |
if [[ $unreleased_commits == 1 ]]; then | |
echo "::set-output name=unreleased-commits::The last chart was last released in $last_revision and there have been other changes in the chart since" | |
fi | |
- name: Let user know merging will cause a release | |
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 | |
with: | |
github-token: ${{ secrets.WEAVE_GITOPS_BOT_ACCESS_TOKEN }} | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: "Merging this will release a new helm chart. ${{ steps.extra.outputs.unreleased-commits }}" | |
}) | |
helm-release: | |
runs-on: ubuntu-latest | |
needs: helm-new-version | |
if: (github.event_name == 'push' && needs.helm-new-version.outputs.old-version != needs.helm-new-version.outputs.new-version) || github.event_name == 'workflow_dispatch' | |
permissions: | |
packages: write # needed for ghcr access | |
steps: | |
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
- name: Find new version | |
id: new_version | |
run: | | |
NEW_VERSION=$(yq e '.version' charts/gitops-server/Chart.yaml) | |
echo "::set-output name=version::$NEW_VERSION" | |
- name: Generate new chart | |
run: | | |
URL=https://helm.gitops.weave.works | |
mkdir helm-release | |
helm package charts/gitops-server/ -d helm-release | |
curl -O $URL/index.yaml | |
helm repo index helm-release --merge=index.yaml --url=$URL | |
- id: auth | |
uses: google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033 # v1.1.1 | |
with: | |
credentials_json: ${{ secrets.PROD_DOCS_GITOPS_UPLOAD }} | |
- id: upload-file | |
uses: google-github-actions/upload-cloud-storage@e95a15f226403ed658d3e65f40205649f342ba2c # v1.0.3 | |
with: | |
path: helm-release | |
destination: helm.gitops.weave.works | |
parent: false | |
- name: Log in to the Container registry | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish chart as an OCI image | |
run: | | |
helm push helm-release/weave-gitops-${{ steps.new_version.outputs.version }}.tgz oci://${{ env.REGISTRY }}/${{ env.CHART_LOCATION }} |