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