1
+ name : Ink_Version_Update
2
+
3
+ on :
4
+ workflow_dispatch :
5
+ schedule :
6
+ - cron : ' 0 6 * * *'
7
+
8
+ jobs :
9
+ get_versions :
10
+ runs-on : ubuntu-latest
11
+ steps :
12
+ - name : Install Rust toolchain
13
+ uses : actions-rs/toolchain@v1
14
+ with :
15
+ profile : minimal
16
+ toolchain : nightly
17
+ components : rustfmt
18
+ - name : Checkout
19
+ uses : actions/checkout@v3
20
+ - name : Install jq
21
+ run : sudo apt -y install jq
22
+ - name : Fetch versions
23
+ run : bash ./scripts/generate_ink_releases.sh
24
+ - name : Show versions
25
+ run : cat ./config/ink_versions.json
26
+ - name : Generate versions variables and PR name
27
+ id : version_info
28
+ run : |
29
+ latest_ink_version=$(cat ./config/ink_versions.json | jq -r '.[0]')
30
+ echo "ink_version_changed=$(git diff --quiet -- ./config/ink_versions.json && echo 'false' || echo 'true')" >> $GITHUB_OUTPUT
31
+ echo "latest_ink_version=${latest_ink_version}" >> $GITHUB_OUTPUT
32
+ echo "ink_update_pr_name=[auto-generated] add new ink version: ${latest_ink_version}" >> $GITHUB_OUTPUT
33
+ - name : Update contract
34
+ if : ${{ steps.version_info.outputs.ink_version_changed == 'true' }}
35
+ run : bash ./scripts/update_ink_version_to_latest.sh
36
+ - name : Commit
37
+ if : ${{ steps.version_info.outputs.ink_version_changed == 'true' }}
38
+ run : |
39
+ git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
40
+ git config --global user.name "github-actions[bot]"
41
+ git status
42
+ git add ./Cargo.lock
43
+ git add ./config/ink_versions.json
44
+ git add ./crates
45
+ git commit -m "update ink version list, latest version: ${{ steps.version_info.outputs.latest_ink_version }}"
46
+ - name : Duplicate PR check
47
+ uses : actions/github-script@v6
48
+ with :
49
+ script : |
50
+ const prName = '${{ steps.version_info.outputs.ink_update_pr_name }}'
51
+ const otherPRs = await github.graphql(`
52
+ query {
53
+ repository(owner: "${{ github.repository_owner }}", name: "ink-playground") {
54
+ pullRequests(labels: ["INK_VERSION"], last: 100, states: [MERGED, OPEN]) {
55
+ edges {
56
+ node {
57
+ title
58
+ labels(first: 100) {
59
+ nodes {
60
+ name
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+ `);
69
+
70
+ console.log({otherPRs})
71
+
72
+ const otherPRsWithSameNameAndLabels = otherPRs.repository.pullRequests.edges.filter(edge => {
73
+ const otherPrName = edge.node.title;
74
+ return prName === otherPrName;
75
+ });
76
+
77
+ if (otherPRsWithSameNameAndLabels.length > 0) {
78
+ throw new Error('Open PR name and label must be unique');
79
+ }
80
+ - name : Create Pull Request
81
+ id : cpr
82
+ uses : peter-evans/create-pull-request@v5
83
+ with :
84
+ token : ${{ secrets.GITHUB_TOKEN }}
85
+ commit-message : Update report
86
+ committer :
GitHub <[email protected] >
87
+ author : ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
88
+ signoff : false
89
+ branch : ink-version-${{ steps.version_info.outputs.latest_ink_version }}
90
+ delete-branch : true
91
+ title : ${{ steps.version_info.outputs.ink_update_pr_name }}
92
+ body : |
93
+ Update report
94
+ - Updated the Ink version to ${{ steps.version_info.outputs.latest_ink_version }}
95
+ - Auto-generated by [create-pull-request][1]
96
+
97
+ [1]: https://github.com/peter-evans/create-pull-request
98
+ labels : |
99
+ INK_VERSION
100
+ github_actions
101
+ draft : false
0 commit comments