Skip to content
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

feature: CI/CD Merges (next->next-major and next->main) #175

Merged
merged 35 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c9896f7
Push new workflow
kschrief Feb 23, 2024
0372e6e
Remove scary github actions
kschrief Feb 23, 2024
82f409f
Update
kschrief Feb 23, 2024
fa37994
Trigger
kschrief Feb 23, 2024
b1fe3bd
Trigger
kschrief Feb 23, 2024
f5ac990
Trigger
kschrief Feb 23, 2024
806e737
Introduce conflict
kschrief Feb 23, 2024
b423f5c
Yes. Good.
kschrief Feb 23, 2024
2aa497c
Get version number
kschrief Feb 27, 2024
337d36e
Get version number
kschrief Feb 27, 2024
90895c6
Get version number
kschrief Feb 27, 2024
d829527
Commit version change
kschrief Feb 27, 2024
3cdbd3c
Commit version change
kschrief Feb 27, 2024
814e1b5
Commit version change
kschrief Feb 27, 2024
37a11a0
Exit 0
kschrief Feb 27, 2024
a6bd102
Versions
kschrief Feb 27, 2024
70025d4
Versions
kschrief Feb 27, 2024
39fe788
Versions
kschrief Feb 27, 2024
9849b7c
Versions
kschrief Feb 27, 2024
63c4013
Conflict
kschrief Feb 27, 2024
cf09ec1
Conflict
kschrief Feb 27, 2024
dddf189
Conflict
kschrief Feb 27, 2024
0848c86
Conflict
kschrief Feb 27, 2024
e6171a9
Conflict
kschrief Feb 27, 2024
fa25feb
Finishing touches
kschrief Feb 28, 2024
b2a5c5f
Finishing touches
kschrief Feb 28, 2024
d4690ba
Merge to main
kschrief Feb 28, 2024
e67ba1f
Change next->main script
kschrief Feb 28, 2024
682a750
Better commit message
kschrief Feb 28, 2024
8aab3df
Better commit message
kschrief Feb 28, 2024
3b81a54
Reverse temporary changes
kschrief Mar 8, 2024
40c70b6
Reverse versioning override
kschrief Mar 25, 2024
5ebcecc
Silly change
kschrief Mar 25, 2024
2ca3e70
Forgot to checkout next-major
kschrief Mar 25, 2024
23bc305
Merge branch 'next' into next
kschrief Apr 2, 2024
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
130 changes: 130 additions & 0 deletions .github/workflows/merge-to-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: Attempt to merge next to main
on:
workflow_dispatch:

jobs:
# Check if next can merge into main
check_merge:
name: Check 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 }}"

# Get the "next" version number
- name: Extract next version
id: extract_version
run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')"

# Checkout "main"
- name: Checkout main
run: git checkout "main"

# Update "main" version to match "next"
- name: Update "main" version to match "next"
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

# 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
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 }}"

# Get the "next" version number
- name: Extract next version
id: extract_version
run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')"

# Checkout "main"
- name: Checkout main
run: git checkout "main"

# Update "main" version to match "next"
- name: Update "main" version to match "next"
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

- name: Perform the merge from next to main
run: |
git merge origin/next
merge_status=$?

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

# If the merge cannot be performed, let stakeholders know
process_merge_on_failure:
name: Merge dry-run failure
needs: check_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"
133 changes: 133 additions & 0 deletions .github/workflows/merge-to-next-major.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Attempt to merge next to next-major
on:
workflow_dispatch:
push:
branches:
- "next"

jobs:
# Check if next can merge into next-major
check_merge:
name: Check 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 }}"

# Get the "next" version number
- name: Extract next version
id: extract_version
run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')"

# Checkout "next-major"
- name: Checkout next-major
run: git checkout "next-major"

# Update "next-major" version to match "next"
- name: Update "next-major" version to match "next"
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

# 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 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
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 }}"

# Get the "next" version number
- name: Extract next version
id: extract_version
run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')"

# Checkout "next-major"
- name: Checkout next-major
run: git checkout "next-major"

# Update "next-major" version to match "next"
- name: Update "next-major" version to match "next"
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

- name: Perform the merge from next to next-major
run: |
git merge origin/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

# If the merge cannot be performed, let stakeholders know
process_merge_on_failure:
name: Merge dry-run failure
needs: check_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"
Loading