Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/pipeline-deploy-to-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ jobs:
with:
build-environment: dev
upload-artifact: ${{ needs.build-dev-apk.outputs.build-artifact }}

trigger-lt-upload:
uses: ./.github/workflows/reusable-lambdatest-upload.yml
secrets: inherit
needs:
- deploy-to-firebase
52 changes: 52 additions & 0 deletions .github/workflows/reusable-check-recent-merges.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Checks if there were merge commits in the last 'days-ago' days
name: "[Reusable] Check if there are recent merges"

on:
workflow_call:
inputs:
days-ago:
type: number
description: "Amount of days to look back for merges"
default: 7

outputs:
has-recent-merges:
description: "True if there were merges in the last 'days-ago' days"
value: ${{ jobs.check-merges.outputs.has-recent-merges }}

jobs:
check-merges:
runs-on: ubuntu-latest

outputs:
has-recent-merges: ${{ steps.check-merges.outputs.has-recent-merges }}

steps:
- name: Checkout code (optional, only if you need repo files for other reasons)
uses: actions/checkout@v4
with:
fetch-depth: 50 # Adjust as needed, 0 for full history

- name: Check for recent merges
id: check-merges
env:
TARGET_BRANCH: ${{ github.ref_name }}
DAYS_AGO: ${{ inputs.days-ago }}
run: |
echo "Checking for merges to $TARGET_BRANCH in the last $DAYS_AGO days."

cutoff_date_seconds=$(date -v -${DAYS_AGO}d +%s)
recent_merge_commit=$(git log $TARGET_BRANCH --merges --since="$DAYS_AGO days ago" --pretty=format:"%ct" -n 1)

if [[ -n "$recent_merge_commit" ]]; then
if (( $recent_merge_commit > cutoff_date_seconds )); then
echo "Found recent merge commit on $TARGET_BRANCH: $commit_hash at $(date -d @$commit_timestamp)"
echo "has-recent-merges=true" >> $GITHUB_OUTPUT
else
echo "No *recent* merge commits found on $TARGET_BRANCH in the last $DAYS_AGO days."
echo "has-recent-merges=false" >> $GITHUB_OUTPUT
fi
else
echo "No merge commits found on $TARGET_BRANCH in the last $DAYS_AGO days using 'git log --merges'."
echo "has-recent-merges=false" >> $GITHUB_OUTPUT
fi
23 changes: 23 additions & 0 deletions .github/workflows/reusable-lambdatest-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Calls upload workflow in the automated test repository
name: "[Reusable] Trigger APK upload to LambdaTest"

on:
workflow_call:

jobs:
trigger_other_workflow:
runs-on: ubuntu-latest
steps:
- name: Trigger upload workflow in automation repository
env:
AUTOMATION_REPO_ACCESS_TOKEN: ${{ secrets.GH_PACKAGE_TOKEN }}
OWNER_AND_REPO: "Simprints/SID-e2e-tests"
WORKFLOW_FILE_NAME: "flow-apk-upload.yml"
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $AUTOMATION_REPO_ACCESS_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/$OWNER_AND_REPO/actions/workflows/$WORKFLOW_FILE_NAME/dispatches" \
-d '{"ref":"main"}'
24 changes: 24 additions & 0 deletions .github/workflows/scheduled-deploy-dev-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "[Manual][Scheduled] Periodic Dev Deploy Workflow"


on:
workflow_call: # For testing purposes
schedule:
- cron: '0 18 * * 4' # End of day on Thursday

concurrency:
group: deploy-main-workflow
cancel-in-progress: true

jobs:
check-recent-merges:
uses: ./.github/workflows/reusable-check-recent-merges.yml
secrets: inherit
with:
days-ago: ${{ vars.DEV_UPLOAD_DAYS_AGO }}

deploy-to-dev:
needs: check-recent-merges
if: needs.check-recent-merges.outputs.has-recent-merges == 'true'
uses: ./.github/workflows/pipeline-deploy-to-dev.yml
secrets: inherit
Loading