-
Notifications
You must be signed in to change notification settings - Fork 1
Add lightweight mt-check-release-needed workflow to trigger release on stale tag or data changes
#684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
15
commits into
master
Choose a base branch
from
copilot/create-mt-check-release-needed-yml
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+93
−0
Draft
Add lightweight mt-check-release-needed workflow to trigger release on stale tag or data changes
#684
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b44d148
Initial plan
Copilot 40eeaf8
Add mt-check-release-needed workflow
Copilot 64e727e
Improve mt-check-release-needed trigger handling
Copilot a8abc26
Clarify data path diff behavior in release check workflow
Copilot d9dbfa9
Polish release-check workflow logging and path comments
Copilot 89887e5
Refine mt-release trigger failure guidance
Copilot eb42ab3
Adjust permission wording in trigger failure message
Copilot 73f1ea6
Correct token scope guidance in trigger error message
Copilot 8c11471
Clarify expected mt-release workflow file location
Copilot df66538
Clarify seven-week constant calculation
Copilot c5a8d60
Align trigger failure message with MT_PAT usage
Copilot dea570b
Merge remote-tracking branch 'origin/master' into copilot/create-mt-c…
mmathieum e677e77
PR comment
mmathieum 1fab13a
Split release-needed decision and trigger into separate steps
Copilot 8e1a29e
Merge branch 'master' into copilot/create-mt-check-release-needed-yml
mmathieum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
shared-overwrite/.github/workflows/mt-check-release-needed.yml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # ORIGINAL FILE: https://github.com/mtransitapps/commons/tree/master/shared-overwrite | ||
| name: MT check release needed | ||
| on: | ||
| workflow_dispatch: # manual | ||
| push: | ||
| branches: | ||
| - 'master' # default | ||
| # gh workflow run mt-check-release-needed.yml --ref $(git rev-parse --abbrev-ref HEAD) | ||
| # gh run list --workflow=mt-check-release-needed.yml | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| MT-CHECK-RELEASE-NEEDED-JOB: | ||
| name: "MT Check Release Needed" | ||
| timeout-minutes: 5 | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: MT check out main repository code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| token: ${{ secrets.MT_PAT }} | ||
| fetch-depth: 0 # required for release tags & history | ||
|
|
||
| - name: MT check if release is needed | ||
| run: | | ||
| echo ">> Checking if release is needed..." | ||
|
|
||
| trigger_release_workflow() { | ||
| echo ">> Triggering mt-release.yml workflow..." | ||
| if ! gh workflow run mt-release.yml; then | ||
| echo ">> Failed to trigger mt-release.yml workflow. Verify GH_TOKEN (from MT_PAT) has workflow scope and '.github/workflows/mt-release.yml' exists on default branch." | ||
| exit 1 | ||
| fi | ||
| echo ">> mt-release.yml workflow triggered." | ||
| } | ||
|
|
||
| APP_ANDROID_MAIN_DIR="app-android/src/main" | ||
| if [[ ! -d "${APP_ANDROID_MAIN_DIR}" ]]; then | ||
| echo ">> No app-android directory found. Release check not applicable." | ||
| exit 0 | ||
| fi | ||
|
|
||
| LAST_GIT_TAG_NAME=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | ||
| if [[ -z "${LAST_GIT_TAG_NAME}" ]]; then | ||
| echo ">> No release tag found." | ||
| trigger_release_workflow | ||
| exit 0 | ||
| fi | ||
|
|
||
| LAST_GIT_TAG_TIMESTAMP_SEC=$(git log -1 --pretty=format:"%at" "${LAST_GIT_TAG_NAME}") | ||
| LAST_GIT_TAG_DATE_TIME=$(date --date='@'"${LAST_GIT_TAG_TIMESTAMP_SEC}"'') | ||
| echo "> Last release '${LAST_GIT_TAG_NAME}' on '${LAST_GIT_TAG_DATE_TIME}'." | ||
|
|
||
| NOW_TIMESTAMP_SEC=$(date +%s) | ||
| MIN_DIFF_FOR_RELEASE_SEC=4233600 # 7 weeks (7 * 7 * 24 * 60 * 60) | ||
| RELEASE_TOO_OLD=false | ||
| if (( NOW_TIMESTAMP_SEC - LAST_GIT_TAG_TIMESTAMP_SEC > MIN_DIFF_FOR_RELEASE_SEC )); then | ||
| RELEASE_TOO_OLD=true | ||
| echo ">> Last release is older than 7 weeks." | ||
| else | ||
| echo ">> Last release is recent enough." | ||
| fi | ||
|
|
||
| DATA_CHANGED=false | ||
| # files are checked directly; raw directories are checked recursively for any file change | ||
| DATA_PATHS=( | ||
| "app-android/src/main/res/values/gtfs_rts_values_gen.xml" | ||
| "app-android/src/main/res/raw/" # git diff checks directory recursively | ||
| "app-android/src/main/res-current/values/current_gtfs_rts_values_gen.xml" | ||
| "app-android/src/main/res-current/raw/" # git diff checks directory recursively | ||
| "app-android/src/main/res-next/values/next_gtfs_rts_values_gen.xml" | ||
| "app-android/src/main/res-next/raw/" # git diff checks directory recursively | ||
| ) | ||
|
|
||
| if ! git diff --quiet "${LAST_GIT_TAG_NAME}"..HEAD -- "${DATA_PATHS[@]}"; then | ||
| echo ">> Data changed since '${LAST_GIT_TAG_NAME}':" | ||
| git diff --name-only "${LAST_GIT_TAG_NAME}"..HEAD -- "${DATA_PATHS[@]}" | ||
| DATA_CHANGED=true | ||
| fi | ||
|
|
||
| if [[ "${RELEASE_TOO_OLD}" == "true" || "${DATA_CHANGED}" == "true" ]]; then | ||
| echo ">> Release needed." | ||
| trigger_release_workflow | ||
| else | ||
| echo ">> Release not needed." | ||
| fi | ||
| env: | ||
| GH_TOKEN: ${{ secrets.MT_PAT }} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.