diff --git a/.github/workflows/pipeline-deploy-to-dev.yml b/.github/workflows/pipeline-deploy-to-dev.yml index 6ea3ea0fe0..085789a8ef 100644 --- a/.github/workflows/pipeline-deploy-to-dev.yml +++ b/.github/workflows/pipeline-deploy-to-dev.yml @@ -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 diff --git a/.github/workflows/reusable-check-recent-merges.yml b/.github/workflows/reusable-check-recent-merges.yml new file mode 100644 index 0000000000..c425023bd6 --- /dev/null +++ b/.github/workflows/reusable-check-recent-merges.yml @@ -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 diff --git a/.github/workflows/reusable-lambdatest-upload.yml b/.github/workflows/reusable-lambdatest-upload.yml new file mode 100644 index 0000000000..de4224127e --- /dev/null +++ b/.github/workflows/reusable-lambdatest-upload.yml @@ -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"}' diff --git a/.github/workflows/scheduled-deploy-dev-workflow.yml b/.github/workflows/scheduled-deploy-dev-workflow.yml new file mode 100644 index 0000000000..fbc2d20af4 --- /dev/null +++ b/.github/workflows/scheduled-deploy-dev-workflow.yml @@ -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