Search code examples
github-actions

How to commit file .REAL_VERSION on PR and not trigger build with github actions?


We have a specific process we are looking to port from circleCI potentially if this works

  1. Developer post PR
  2. CI job 'buildMyStuff' triggers off the PR (or any changes except to .REAL_VERSION)
  3. CI job 'buildMyStuff' adds and commits .REAL_VERSION with circleCI build number(used in git tag and CD in deploy job)
  4. Here we want to prevent CI job 'buildMyStuff' doing a recursive build as it sees the PR changed (because it pushed .REAL_VERSION)
  5. Developer sees build pass and 1 day later merge squashes into master/main branch
  6. Now job "deployMyStuff' runs and does git tag using contents of .REAL_VERSION so it can re-use the artifacts built from CI in the previous step #2 since they are 100% guaranteed to be the same and do not need rebuilding(saving a ton of time and build credits). It also deploys to staging environment

NOTE on step #5 - If branch is not up to date with master, developer has to click update to master kicking off a new build again (you have to be up to date with master AND CI passing before merge)

Now, in circleCI, committing .REAL_VERSION triggers another build(ie. step 4 above) and using their special [ci skip] does not work since that results in skipping the next build AND THEN the deploy job too(ie. steps 4 and .

Basically, we want a CI build to commit ONE file during PR but not trigger any builds either ignoring because of

  1. author of commit (circleci user perhaps)
  2. OR [ci skip 'job name'] in comment of git message
  3. OR never build on changes to .REAL_VERSION
  4. OR something else to prevent that 1 build

Can we do this on github builds?


Solution

  • In regards to ignoring certain files in the trigger, you can scope this with the paths-ignore option.

    on:
      push:
        branches:
          - main
        paths-ignore:
          - '.REAL_VERSION'