PR to update Charts #17
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: PR to update Charts | |
# This action will run automatically after the workflow "Publish container" is completed | |
on: | |
workflow_run: | |
workflows: ["Publish container"] | |
types: | |
- completed | |
workflow_dispatch: | |
env: | |
LATEST_HEADLAMP_TAG: latest | |
jobs: | |
create_pr_to_upgrade_chart: | |
name: Create PR to update Headlamp's version in the Helm Chart | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout headlamp repo | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
user=${{github.actor}} | |
if [ -z $user ]; then | |
user=joaquimrocha | |
fi | |
git config --global user.name "$user" | |
git config --global user.email "$user@users.noreply.github.com" | |
- name: Get headlamp latest tag | |
run: | | |
latestTag=$(git tag --list --sort=version:refname 'v*' | tail -1) | |
echo "LATEST_HEADLAMP_TAG=$latestTag" >> $GITHUB_ENV | |
echo $latestTag | |
- name: Update Headlamp version in charts | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
if [ -z $user ]; then | |
user=joaquimrocha | |
fi | |
# Extract current version | |
CURRENT_CHART_VERSION=$(grep '^version:' ./charts/headlamp/Chart.yaml | cut -d' ' -f2) | |
CURRENT_CHART_VERSION=$(echo $CURRENT_CHART_VERSION | awk -F. -v OFS=. '{$(NF - 1) += 1 ; print}') | |
# Create branch | |
BRANCH=update_chart_headlamp_$LATEST_HEADLAMP_TAG | |
if git branch -l | grep -q $BRANCH; then | |
echo "deleting old branch from local to avoid conflict" | |
git branch -D $BRANCH | |
fi | |
if git branch -a | grep -q "origin/$BRANCH"; then | |
echo "deleting old branch from remote to avoid conflict" | |
git push origin --delete "$BRANCH" | |
fi | |
# Move to new branch | |
git checkout -b $BRANCH | |
sed -i "s/^version:\ .*/version: $CURRENT_CHART_VERSION/g" ./charts/headlamp/Chart.yaml | |
sed -i "s/^appVersion:\ .*/appVersion: $LATEST_HEADLAMP_TAG/g" ./charts/headlamp/Chart.yaml | |
git diff | |
git status | |
git add ./charts/headlamp/Chart.yaml | |
git commit --signoff -m "charts: Bump Headlamp version to $LATEST_HEADLAMP_TAG" | |
git status | |
git log -1 | |
git push origin $BRANCH -f | |
gh pr create \ | |
--title "chart: Bump Headlamp version to $LATEST_HEADLAMP_TAG" \ | |
--base "main" \ | |
--assignee "$user" \ | |
--body "Automatically opened by CI." |