Update version-update.yml #8
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: Update Version based on PR label | |
on: | |
pull_request: | |
types: | |
- closed | |
jobs: | |
version-update: | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.merged == true | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Save PR labels to file | |
run: echo '${{ toJson(github.event.pull_request.labels) }}' > pr_labels.json | |
- name: Determine Version Increment | |
id: vars | |
run: | | |
LABELS=$(jq -r '.[].name' pr_labels.json | tr '\n' ' ') | |
echo "Detected Labels: $LABELS" | |
if echo $LABELS | grep -q "major"; then | |
echo "Detected major label" | |
echo "::set-output name=INCREMENT::major" | |
elif echo $LABELS | grep -q "minor"; then | |
echo "Detected minor label" | |
echo "::set-output name=INCREMENT::minor" | |
elif echo $LABELS | grep -q "patch"; then | |
echo "Detected patch label" | |
echo "::set-output name=INCREMENT::patch" | |
else | |
echo "No version label detected" | |
echo "::set-output name=INCREMENT::" | |
fi | |
- name: Debug PR labels | |
run: echo "${{ toJson(github.event.pull_request.labels) }}" | |
- name: Debug INCREMENT | |
run: echo ${{ steps.vars.outputs.INCREMENT }} | |
- name: Update Project Version with Gradle | |
if: steps.vars.outputs.INCREMENT | |
run: | | |
./gradlew updateVersion --increment=${{ steps.vars.outputs.INCREMENT }} | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git add . | |
git commit -m "chore: update project version based on PR label" | |
git push |