avoid running CI bump loop when packages.json file changed #15
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: Main | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
jobs: | |
detect_changes: | |
name: Detect What Changes Occurred | |
runs-on: ubuntu-latest | |
# Set job outputs to values from filter step | |
outputs: | |
bump_app: ${{ steps.filter.outputs.bump_app }} | |
bump_helm: ${{ steps.filter.outputs.bump_helm }} | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
- uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
filters: | | |
bump_app: | |
- '!cmd/package.json' | |
- 'cmd/**' | |
- 'internal/**' | |
- 'api/**' | |
- 'config/**' | |
bump_build_push: | |
needs: detect_changes | |
if: needs.detect_changes.outputs.bump_app == 'true' | |
name: Bump Application Version | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Bump Application Version in package.json | |
id: version-bump-app | |
uses: 'phips28/gh-action-bump-version@master' | |
with: | |
major-wording: 'major,MAJOR,breaking' | |
minor-wording: 'feat,FEAT,minor,MINOR' | |
patch-wording: 'fix,chore,test,docs,style,refactor,patch' | |
rc-wording: 'RELEASE,alpha' | |
skip-commit: 'true' | |
skip-tag: 'true' | |
skip-push: 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PACKAGEJSON_DIR: 'cmd' | |
- name: New Version Output | |
env: | |
NEW_TAG: ${{ steps.version-bump-app.outputs.newTag }} | |
run: echo "New version $NEW_TAG" | |
- name: Retrieve Docker Image Name with Tag | |
run: | | |
echo "IMG_NAME_AND_TAG=$(make docker_img_name_and_tag)" >> $GITHUB_OUTPUT | |
id: img_name_and_version_tag | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and Publish Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.img_name_and_version_tag.outputs.IMG_NAME_AND_TAG }} | |
- name: Commit Files | |
run: | | |
git config --local user.email "sitedeployaction@users.noreply.github.com" | |
git config --local user.name "GitHub Action" | |
git commit -am 'CI(version) ${{ steps.version-bump-app.outputs.newTag }}' | |
git tag ${{ steps.version-bump-app.outputs.newTag }} | |
- name: Push Changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GH_TOKEN }} | |
branch: main | |
tags: true |