fix(release-gha): Fixing git commands #35
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: Release Charts on Merge | |
on: | |
pull_request: | |
types: [closed] | |
branches: | |
- main | |
jobs: | |
release-on-merge: | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout 'gh-pages' branch | |
uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
fetch-depth: 0 | |
persist-credentials: true | |
- name: Configure Git | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
git merge origin/main --no-edit | |
- name: Installer jq | |
run: sudo apt-get install jq | |
- name: Check 'release' Label | |
id: check_release_label | |
run: | | |
labels='${{ toJSON(github.event.pull_request.labels) }}' | |
echo "Labels de la PR : $labels" | |
if echo "$labels" | jq -e '.[] | select(.name=="release")' > /dev/null; then | |
echo "has_release_label=true" >> $GITHUB_ENV | |
else | |
echo "has_release_label=false" >> $GITHUB_ENV | |
fi | |
- name: Lint Chart - Main chart | |
if: env.has_release_label == 'true' | |
run: helm lint . | |
- name: Update Dependencies | |
if: env.has_release_label == 'true' | |
run: helm dependency update . | |
- name: Deploy to GitHub Pages | |
if: env.has_release_label == 'true' | |
run: | | |
helm package . --destination charts/ | |
helm repo index . --url https://getlago.github.io/charts | |
git add . | |
git commit -m "Update Helm repo index after release" | |
git pull | |
git status | |
git push origin gh-pages | |
- name: Extract version from Chart.yaml | |
if: env.has_release_label == 'true' | |
id: get_version | |
run: | | |
version=$(grep '^version:' Chart.yaml | awk '{print $2}') | |
echo "Extracted version: $version" | |
echo "version=$version" >> $GITHUB_ENV | |
- name: Create Git tag | |
if: env.has_release_label == 'true' | |
run: | | |
git tag "v${{ env.version }}" | |
git push origin "v${{ env.version }}" | |
- name: Create GitHub Release | |
if: env.has_release_label == 'true' | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "v${{ env.version }}" | |
release_name: "Release v${{ env.version }}" | |
body: "Release of version v${{ env.version }}" | |
draft: false | |
prerelease: false |