diff --git a/.github/workflows/merge-to-main.yml b/.github/workflows/merge-to-main.yml index 02f60a451..2c4c8f1df 100644 --- a/.github/workflows/merge-to-main.yml +++ b/.github/workflows/merge-to-main.yml @@ -4,40 +4,9 @@ on: jobs: # Check if next can merge into main - check_merge: - name: Check if "next" can merge into "main" + perform_merge: + name: Perform merge if "next" can merge into "main" runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - repo-token: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} - persist-credentials: true - - # Set user identity - - name: Set-Identity - run: | - git config --global user.email "${{ secrets.GLOBAL_GITHUB_EMAIL }}" - git config --global user.name "${{ secrets.GLOBAL_GITHUB_USER }}" - - # Checkout "main" - - name: Checkout main - run: git checkout "main" - - # Attempt a dry-run merge - - name: Attempt a dry-run merge - run: | - git merge --no-commit --no-ff origin/${{github.ref_name}} - exit $? - - # Attempt to merge to main if our dry-run succeeded - process_merge_on_success: - name: Perform merge from "next" to "main" - needs: check_merge - runs-on: ubuntu-latest - if: ${{ success() }} - steps: - name: Checkout uses: actions/checkout@v2 @@ -58,37 +27,17 @@ jobs: - name: Perform the merge from next to main run: | - git merge origin/next - merge_status=$? - + git merge next git push origin "main" - push_status=$? - - if [ "$merge_status" -eq 0 ] && [ "$push_status" -eq 0 ]; then - echo "Push to main succeeded" - exit 0 - else - exit 1 - fi + echo "Push to main succeeded" - # If the merge cannot be performed, let stakeholders know - process_merge_on_failure: - name: Merge dry-run failure - needs: check_merge + # If the merge cannot be performed, let stakeholders know + message_on_failure: + name: Merge failure + needs: perform_merge runs-on: ubuntu-latest if: ${{ failure() }} steps: - name: Post error message (To-Do) run: echo "Next cannot be merged into main cleanly" - - # If we attempted to merge/push to next-main but there was a failure - process_push_failure: - name: Merge failure - needs: process_merge_on_success - runs-on: ubuntu-latest - if: ${{ failure() && needs.process_merge_on_success.result != 'skipped' }} - - steps: - - name: Post error message (To-Do) - run: echo "There was a failure when merging next into main" diff --git a/.github/workflows/merge-to-next-major.yml b/.github/workflows/merge-to-next-major.yml index b8d080c96..f0066b908 100644 --- a/.github/workflows/merge-to-next-major.yml +++ b/.github/workflows/merge-to-next-major.yml @@ -7,66 +7,9 @@ on: jobs: # Check if next can merge into next-major - check_merge: - name: Check if "next" can merge into "next-major" + perform_merge: + name: Perform merge if "next" can merge into "next-major" runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - repo-token: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} - persist-credentials: true - - # Set user identity - - name: Set-Identity - run: | - git config --global user.email "${{ secrets.GLOBAL_GITHUB_EMAIL }}" - git config --global user.name "${{ secrets.GLOBAL_GITHUB_USER }}" - - # Checkout "next-major" - - name: Checkout next-major - run: git checkout "next-major" - - # Get the "next-major" version number - - name: Extract next-major version - id: extract_version - run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')" - - # Checkout "next" - - name: Checkout next - run: git checkout "next" - - # Update "next" version to match "next-major" - - name: Update "next" version to match "next-major" - run: | - jq '.version = "${{ steps.extract_version.outputs.version }}"' package.json > temp.json - - if diff -q "package.json" "temp.json" >/dev/null; then - echo "Versions are identical. No change required." - rm temp.json - else - mv temp.json package.json - git add package.json && git commit -m "Sync version to ${{ steps.extract_version.outputs.version }}" - fi - - # Checkout "next-major" - - name: Checkout next-major - run: git checkout "next-major" - - # Attempt a dry-run merge - - name: Attempt a dry-run merge - run: | - git merge --no-commit --no-ff ${{github.ref_name}} - exit $? - - # Attempt to merge to next-major if our dry-run succeeded - process_merge_on_success: - name: Perform merge from "next" to "next-major" - needs: check_merge - runs-on: ubuntu-latest - if: ${{ success() }} - steps: - name: Checkout uses: actions/checkout@v2 @@ -114,36 +57,16 @@ jobs: - name: Perform the merge from next to next-major run: | git merge next - merge_status=$? - git push origin "next-major" - push_status=$? - - if [ "$merge_status" -eq 0 ] && [ "$push_status" -eq 0 ]; then - echo "Push to next-major succeeded" - exit 0 - else - exit 1 - fi + echo "Push to next-major succeeded" # If the merge cannot be performed, let stakeholders know - process_merge_on_failure: - name: Merge dry-run failure - needs: check_merge + message_on_failure: + name: Merge failure + needs: perform_merge runs-on: ubuntu-latest if: ${{ failure() }} steps: - name: Post error message (To-Do) run: echo "Next cannot be merged into next-major cleanly" - - # If we attempted to merge/push to next-main but there was a failure - process_push_failure: - name: Merge failure - needs: process_merge_on_success - runs-on: ubuntu-latest - if: ${{ failure() && needs.process_merge_on_success.result != 'skipped' }} - - steps: - - name: Post error message (To-Do) - run: echo "There was a failure when merging next into next-major"