diff --git a/.github/workflows/create_pull_request.yml b/.github/workflows/create_pull_request.yml new file mode 100644 index 00000000..248e4ed1 --- /dev/null +++ b/.github/workflows/create_pull_request.yml @@ -0,0 +1,32 @@ +name: Create Pull Request + +on: + workflow_call: + inputs: + branch_name: + description: "Branch name to create PR from" + required: true + type: string + PR_message: + description: "PR Message" + required: false + default: Automated PR generated using GHA + type: string + +jobs: + create_pull_request: + name: Create Pull Request + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Create Pull Request + run: | + gh pr create \ + --title "Automated tide pull request for release {{ release }}" \ + --body "${{ inputs.PR_message }}" \ + --base develop \ + --head ${{ inputs.branch_name }} \ + --repo ${{ github.repository }} diff --git a/.github/workflows/force_push_to_uat.yml b/.github/workflows/force_push_to_uat.yml index ab53840d..34e29cf9 100644 --- a/.github/workflows/force_push_to_uat.yml +++ b/.github/workflows/force_push_to_uat.yml @@ -1,45 +1,41 @@ name: force_push_to_uat -on: +on: workflow_call: + inputs: + branch_name: + description: "Branch name to push changes to (e.g., release/SCFA-1234)" + required: true + type: string jobs: force_push_to_uat: - name: force_push_to_uat - if: startsWith(github.event.branches[0].name, 'release/') + name: Force Push Branch to UAT runs-on: ubuntu-latest + steps: - name: Checkout code uses: actions/checkout@v4 - - name: Output caller branch - run: echo ${{ github.event.branches[0].name }} - - name: Output tested commit - run: echo ${{ github.event.branches[0].commit.sha }} - - name: Determine status state - run: | - output=$(curl -L \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/${{ github.repository }}/commits/${{ github.event.branches[0].commit.sha }}/status) + with: + fetch-depth: 0 # Fetch full branch history - api_status=$(echo "$output" | jq -r '.statuses[] | select(.context == "api") | .state') - e2e_status=$(echo "$output" | jq -r '.statuses[] | select(.context == "e2e_be") | .state') - build_status=$(echo "$output" | jq -r '.statuses[] | select(.context == "tide_build") | .state') + - name: Fetch and Pull Latest Changes + run: | + git fetch origin "${{ inputs.branch_name }}" + git checkout "${{ inputs.branch_name }}" + git pull origin "${{ inputs.branch_name }}" # Ensure latest commits are present - echo "API test status is $api_status" - echo "E2E test status is $e2e_status" - echo "Build status is $build_status" + - name: Log Branch State + run: | + echo "Branch state before force-push:" + git log --oneline -5 - if [[ $api_status == "success" && $e2e_status == "failure" && $build_status == "failure" ]]; then - echo "==> All checks passed, deploying to UAT." - exit 0 - else - echo "==> Checks pending or failed, holding." - exit 1 - fi - - name: Force push + - name: Force Push to UAT + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - cd ${GITHUB_WORKSPACE} - chmod +x .circleci/force-push-to-uat.sh - .circleci/force-push-to-uat.sh \ No newline at end of file + git push origin "${{ inputs.branch_name }}:uat" --force + + - name: Notify Completion + if: success() + run: echo "Branch ${{ inputs.branch_name }} has been force pushed to UAT." diff --git a/.github/workflows/rel_export_config.yml b/.github/workflows/rel_export_config.yml new file mode 100644 index 00000000..f225837a --- /dev/null +++ b/.github/workflows/rel_export_config.yml @@ -0,0 +1,59 @@ +name: export_config + +on: + workflow_call: + inputs: + branch_name: + description: "Branch name to export config and push changes (e.g., release/SCFA-1234)" + required: true + type: string + +env: + REGISTRY: ghcr.io + +jobs: + export_config: + name: Export Config and Push to Branch + runs-on: biggy + container: + image: ghcr.io/dpc-sdp/bay/ci-builder:5.x + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Log into registry ghcr.io + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Uncomment database snapshot environment variable + run: | + sed -i 's|# DB_IMAGE_SNAPSHOT|DB_IMAGE_SNAPSHOT|' .env + + - name: Configure Git + run: | + git config --global user.email "${{ secrets.DEPLOY_USER_EMAIL }}" && git config --global user.name "${{ secrets.DEPLOY_USER_NAME }}" + + - name: Copy repo + run: | + chown -R $(id -u):$(id -g) $PWD + cp -R ${GITHUB_WORKSPACE} /app + + - name: Run export script + run: | + cd /app + scripts/export-config-push-uat.sh "${{ inputs.branch_name }}" + env: + DEPLOY_USER_EMAIL: ${{ secrets.DEPLOY_USER_EMAIL }} + DEPLOY_USER_NAME: ${{ secrets.DEPLOY_USER_NAME }} + + - name: Notify completion + if: success() + run: | + echo "Export config completed and pushed to branch ${{ inputs.branch_name }}."