Skip to content

Commit 09633c8

Browse files
Bump json from 2.10.1 to 2.10.2 (#58)
* Bump json from 2.10.1 to 2.10.2 Bumps [json](https://github.com/ruby/json) from 2.10.1 to 2.10.2. - [Release notes](https://github.com/ruby/json/releases) - [Changelog](https://github.com/ruby/json/blob/master/CHANGES.md) - [Commits](ruby/json@v2.10.1...v2.10.2) --- updated-dependencies: - dependency-name: json dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> * added additional workflows Signed-off-by: George M Dias <[email protected]> * updated merge main into PR workflow Signed-off-by: George M Dias <[email protected]> * updated merge main into PR workflow Signed-off-by: George M Dias <[email protected]> * updated merge main into PR workflow Signed-off-by: George M Dias <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: George M Dias <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: George M Dias <[email protected]>
1 parent 3bb5be3 commit 09633c8

File tree

3 files changed

+133
-1
lines changed

3 files changed

+133
-1
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Auto Merge Main into PR (Only if Main was Updated)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
10+
jobs:
11+
auto-merge:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout PR branch
16+
uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.head_ref }}
19+
20+
- name: Fetch the latest main branch
21+
run: |
22+
git fetch origin main
23+
24+
- name: Get the commit hash of main at the time the PR was created
25+
id: pr_created
26+
run: |
27+
PR_CREATED_COMMIT=$(git log --merges --pretty=format:'%H' origin/main..${{ github.event.pull_request.head.sha }} | tail -n 1)
28+
echo "PR_CREATED_COMMIT=$PR_CREATED_COMMIT" >> $GITHUB_ENV
29+
30+
- name: Check if main was updated since PR was created
31+
id: check_main_update
32+
run: |
33+
# Get the latest commit hash from the main branch
34+
LATEST_MAIN_COMMIT=$(git rev-parse origin/main)
35+
36+
# Compare the commit hashes
37+
if [ "$PR_CREATED_COMMIT" != "$LATEST_MAIN_COMMIT" ]; then
38+
echo "Main has been updated since PR creation"
39+
echo "MAIN_UPDATED=true" >> $GITHUB_ENV
40+
else
41+
echo "Main has not been updated since PR creation"
42+
echo "MAIN_UPDATED=false" >> $GITHUB_ENV
43+
fi
44+
45+
- name: Check if main is already merged into PR
46+
id: check_merge
47+
run: |
48+
# Check if the commit hash of the latest main commit is already in the PR's history
49+
MERGE_COMMIT=$(git log --oneline --merges | grep -m 1 "Merge branch 'main' into" || true)
50+
51+
if [[ -z "$MERGE_COMMIT" ]]; then
52+
echo "Main has not been merged into the PR branch yet"
53+
echo "MERGE_DONE=false" >> $GITHUB_ENV
54+
else
55+
echo "Main has already been merged into the PR branch"
56+
echo "MERGE_DONE=true" >> $GITHUB_ENV
57+
fi
58+
59+
- name: Attempt to merge main into PR branch (if main was updated and not merged yet)
60+
if: env.MAIN_UPDATED == 'true' && env.MERGE_DONE == 'false'
61+
run: |
62+
# Set user info for the merge commit, ensuring dependabot[bot] or another user is identified
63+
# git config --global user.name "GitHub Actions"
64+
# git config --global user.email "[email protected]"
65+
git config --global user.name "github-actions[bot]"
66+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
67+
68+
69+
# Attempt to merge the main branch into the PR branch
70+
git merge --no-ff --no-commit origin/main --allow-unrelated-histories || echo "Merge conflict detected"
71+
# If merge was successful, commit and push
72+
if [ $? -eq 0 ]; then
73+
git commit -m "Auto merge main into PR branch"
74+
git push
75+
fi
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
79+
- name: Handle merge conflicts and notify the user
80+
if: failure() && env.MAIN_UPDATED == 'true' && env.MERGE_DONE == 'false'
81+
run: |
82+
# Leave a comment on the PR about merge conflicts
83+
PR_URL="https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
84+
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"body":"Merge conflicts were detected when attempting to merge `main` into this PR. Please resolve the conflicts manually."}' $PR_URL
85+
86+
# Optionally, print out conflict information for debugging
87+
echo "Merge conflicts occurred. Please resolve them manually."
88+
89+
- name: Skip merge if no updates in main or already merged
90+
if: env.MAIN_UPDATED == 'false' || env.MERGE_DONE == 'true'
91+
run: |
92+
if [ "$MAIN_UPDATED" == "false" ]; then
93+
echo "No new changes in main since the PR was created. Skipping merge."
94+
fi
95+
if [ "$MERGE_DONE" == "true" ]; then
96+
echo "Main has already been merged into the PR branch. Skipping merge."
97+
fi
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Build and Test eMASSer CLI Docker Image on every Pull Request or Push to Main
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
TEST_TAG: emasser:testTag
11+
12+
jobs:
13+
docker:
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v3
18+
- name: Checkout the eMASSer Repository
19+
uses: actions/checkout@v4
20+
- name: Build Docker Image
21+
id: docker_build
22+
uses: docker/build-push-action@v5
23+
with:
24+
context: .
25+
push: false
26+
load: true # makes it available for the local docker executable
27+
# doesn't need multiplatform support since we're only running it in this workflow
28+
tags: ${{ env.TEST_TAG }}
29+
- name: Test
30+
run: |
31+
docker run --rm ${{ env.TEST_TAG }}

Gemfile.lock

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ GEM
3434
ethon (0.16.0)
3535
ffi (>= 1.15.0)
3636
ffi (1.17.1-x64-mingw-ucrt)
37+
ffi (1.17.1-x86_64-linux-gnu)
3738
i18n (1.14.7)
3839
concurrent-ruby (~> 1.0)
3940
jaro_winkler (1.6.0)
40-
json (2.10.1)
41+
json (2.10.2)
4142
kramdown (2.5.1)
4243
rexml (>= 3.3.9)
4344
kramdown-parser-gfm (1.1.0)
@@ -48,6 +49,8 @@ GEM
4849
minitest (5.25.4)
4950
nokogiri (1.18.3-x64-mingw-ucrt)
5051
racc (~> 1.4)
52+
nokogiri (1.18.3-x86_64-linux-gnu)
53+
racc (~> 1.4)
5154
observer (0.1.2)
5255
ostruct (0.6.1)
5356
parallel (1.26.3)
@@ -147,6 +150,7 @@ GEM
147150

148151
PLATFORMS
149152
x64-mingw-ucrt
153+
x86_64-linux
150154

151155
DEPENDENCIES
152156
bundler (~> 2.5)

0 commit comments

Comments
 (0)