Skip to content

Commit fd7be13

Browse files
authored
CI Flow Fix (#1203)
* label PR at the end of extra commits * workflow ref changed for testing * trigger condition fixed * try labeler with GitHub token * maybe with deploy key * check on sync triggers * push trigger working now cleaned up for PR * checks only trigger if PR is ready for review or if it's labeled ready-to-merge * env reference fixed * pre job needs check_commit * added name for pre job
1 parent 70cf235 commit fd7be13

File tree

8 files changed

+70
-43
lines changed

8 files changed

+70
-43
lines changed

.github/workflows/duplicate_samples.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Duplicate Samples
1+
name: Duplicate Samples 🪞
22

33
on:
44
workflow_call:

.github/workflows/pull_request_checks.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/pull_request_checks_dev.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ on:
99
- ready_for_review
1010

1111
jobs:
12-
pull_reqest_checks:
13-
name: Pull Request Checks
14-
uses: ChainSafe/web3.unity/.github/workflows/pull_request_checks.yml@main
15-
secrets: inherit
12+
web3_tests:
13+
name: Web3 tests 🕸
14+
if: ${{ github.event.action == 'ready_for_review' || github.event.label.name == 'ready-to-merge'}}
15+
uses: ChainSafe/web3.unity/.github/workflows/test.yaml@main
16+
analyze_code:
17+
name: Analyze 🧐
18+
if: ${{ github.event.action == 'ready_for_review' || github.event.label.name == 'ready-to-merge'}}
19+
uses: ChainSafe/web3.unity/.github/workflows/codeql.yml@main

.github/workflows/pull_request_checks_main.yml

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,54 @@ on:
77
types:
88
- labeled
99
- ready_for_review
10+
- synchronize
1011

1112
jobs:
12-
pull_reqest_checks:
13-
name: Pull Request Checks
14-
uses: ChainSafe/web3.unity/.github/workflows/pull_request_checks.yml@main
13+
check_commit:
14+
name: Check Commit 📝
15+
runs-on: ubuntu-latest
16+
if: ${{ !github.event.pull_request.draft }}
17+
outputs:
18+
commit_message: ${{ steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE }}
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
ref: ${{ github.head_ref || github.ref_name }}
24+
lfs: true
25+
ssh-key: ${{ secrets.DEPLOY_KEY }}
26+
- name: Get Head Commit Message
27+
id: get_head_commit_message
28+
run: echo "HEAD_COMMIT_MESSAGE=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"
29+
30+
pre_job:
31+
name: Pre Job 🚀
32+
runs-on: ubuntu-latest
33+
if: ${{ needs.check_commit.outputs.commit_message == 'Sync Dependencies - Auto Commit' }}
34+
needs: [ check_commit ]
35+
steps:
36+
- run: echo "..."
37+
38+
web3_tests:
39+
name: Web3 tests 🕸
40+
uses: ChainSafe/web3.unity/.github/workflows/test.yaml@main
41+
needs: [ pre_job ]
42+
analyze_code:
43+
name: Analyze 🧐
44+
uses: ChainSafe/web3.unity/.github/workflows/codeql.yml@main
45+
needs: [ pre_job ]
46+
unity_tests:
47+
name: Unity Tests 🧪
48+
uses: ChainSafe/web3.unity/.github/workflows/unity_tests.yml@main
49+
needs: [ pre_job ]
50+
secrets: inherit
51+
duplicate_samples:
52+
name: Duplicate Samples 🪞
53+
if: ${{ github.event.action == 'ready_for_review' || github.event.label.name == 'ready-to-merge'}}
54+
uses: ChainSafe/web3.unity/.github/workflows/duplicate_samples.yaml@main
55+
secrets: inherit
56+
sync_dependencies:
57+
name: Sync Dependencies 🔄
58+
uses: ChainSafe/web3.unity/.github/workflows/sync_dependencies.yaml@main
59+
needs: [ duplicate_samples ]
1560
secrets: inherit

.github/workflows/sync_branches.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
git config user.email $git_email
3030
git config user.name $git_actor
3131
git fetch origin ${{ github.event.inputs.branch }}
32+
git checkout ${{ github.event.inputs.branch }}
33+
git pull
3234
git merge main --allow-unrelated-histories
3335
git push
3436
shell: bash

.github/workflows/sync_dependencies.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Sync Dependencies
1+
name: Sync Dependencies 🔄
22

33
on:
44
workflow_call:

Setup/Git.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,20 @@ public static void Add(string path)
3434
$"git add \"{path}\" -f".Run();
3535
}
3636

37-
public static void Commit(string message, string[] tags = null)
37+
public static void Commit(string message, string[] tags = null, bool skipCi = true)
3838
{
3939
if (!_configured)
4040
{
4141
Configure();
4242
}
4343

44+
if (skipCi)
45+
{
46+
message += " [skip ci]";
47+
}
48+
4449
// Checks if there are any changes to commit before committing
45-
$"git diff-index --cached --quiet HEAD || git commit -m \"{message} [skip ci]\"".Run();
50+
$"git diff-index --cached --quiet HEAD || git commit -m \"{message}\"".Run();
4651

4752
if (tags != null)
4853
{
@@ -72,9 +77,9 @@ public static void Push(string[] tags = null)
7277
}
7378
}
7479

75-
public static void CommitAndPush(string message, string[] tags = null)
80+
public static void CommitAndPush(string message, string[] tags = null, bool skipCi = true)
7681
{
77-
Commit(message, tags);
82+
Commit(message, tags, skipCi);
7883

7984
Push(tags);
8085
}

Setup/SyncDependencies.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void Run()
7373
Git.Add(destination);
7474
}
7575

76-
Git.CommitAndPush("Sync Dependencies");
76+
Git.CommitAndPush("Sync Dependencies - Auto Commit", skipCi: false);
7777

7878
Console.WriteLine("Dependencies Synced Successfully!");
7979
}

0 commit comments

Comments
 (0)