aboutsummaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorLuau Project <luau.project@gmail.com>2025-06-30 12:17:42 -0300
committerGitHub <noreply@github.com>2025-06-30 12:17:42 -0300
commitb45502ab0f1b7e1a02313036f115c213c8ee0ef9 (patch)
treebebaa8c767f8968c90f6d3000b99d4bc95ac2339 /.github
parent990ec6ca3b097c7160fe925cfca4b8e57cfe5685 (diff)
downloadluarocks-b45502ab0f1b7e1a02313036f115c213c8ee0ef9.tar.gz
luarocks-b45502ab0f1b7e1a02313036f115c213c8ee0ef9.tar.bz2
luarocks-b45502ab0f1b7e1a02313036f115c213c8ee0ef9.zip
ci: automate PR to update LuaRocks version on gh-actions-luarocks (#1808)
On every tagged release of LuaRocks, there is the need to update LuaRocks version at [https://github.com/luarocks/gh-actions-luarocks/blob/22fa5618dc4ddff1fb251b3b38a0766a8c9ae47f/action.yml#L13](https://github.com/luarocks/gh-actions-luarocks/blob/22fa5618dc4ddff1fb251b3b38a0766a8c9ae47f/action.yml#L13) in the repository [https://github.com/luarocks/gh-actions-luarocks](https://github.com/luarocks/gh-actions-luarocks). Often forgotten, the default LuaRocks version on `gh-actions-luarocks` may lag behind the latest LuaRocks release. Motivated by this comment [https://github.com/luarocks/gh-actions-luarocks/pull/7#issuecomment-2997223378](https://github.com/luarocks/gh-actions-luarocks/pull/7#issuecomment-2997223378), to address this problem, incorporating the changes on this pull request, a new workflow was created to proceed in the following manner: 1. Once a tag is pushed (in the usual format `vX.Y.Z`) on [https://github.com/luarocks/luarocks](https://github.com/luarocks/luarocks), or in a manual workflow triggered by the tag ref, a sanitization step is performed to extract `X.Y.Z` from the `vX.Y.Z` in the job `SanitizeVersion`; 2. In a subsequent job (`CreatePullRequest`), a PR is created at [https://github.com/luarocks/gh-actions-luarocks](https://github.com/luarocks/gh-actions-luarocks) replacing the outdated version by the value `X.Y.Z` extracted earlier.
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/pr-gh-actions.yml107
1 files changed, 107 insertions, 0 deletions
diff --git a/.github/workflows/pr-gh-actions.yml b/.github/workflows/pr-gh-actions.yml
new file mode 100644
index 00000000..fa0cd465
--- /dev/null
+++ b/.github/workflows/pr-gh-actions.yml
@@ -0,0 +1,107 @@
1name: PR on GH Actions
2
3on:
4 push:
5 tags:
6 - 'v*'
7 workflow_dispatch:
8
9jobs:
10
11 SanitizeVersion:
12 runs-on: ubuntu-latest
13
14 outputs:
15 version: ${{ steps.version.outputs.version }}
16
17 steps:
18 - name: Extract version from the tag and set it as output
19 id: version
20 run: |
21 if [ "${{ github.ref_type }}" = "tag" ];
22 then
23 version=$(echo "${{ github.ref_name }}" | sed -e "s/v//g" | grep -oP '^(\d+\.\d+\.\d+)$')
24
25 if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]];
26 then
27 echo "version=${version}" >> "$GITHUB_OUTPUT"
28 else
29 echo "version=none" >> "$GITHUB_OUTPUT"
30 fi
31 else
32 echo "version=none" >> "$GITHUB_OUTPUT"
33 fi
34
35 CreatePullRequest:
36 runs-on: ubuntu-latest
37 needs:
38 - SanitizeVersion
39 if: ${{ github.ref_type == 'tag' && needs.SanitizeVersion.outputs.version != 'none' }}
40
41 env:
42 TARGET_REPOSITORY: luarocks/gh-actions-luarocks
43 NEW_BRANCH: luarocks-${{ needs.SanitizeVersion.outputs.version }}
44 NEW_COMMIT_MSG: 'LuaRocks: update to ${{ needs.SanitizeVersion.outputs.version }}'
45 NEW_PR_TITLE: 'LuaRocks: update to ${{ needs.SanitizeVersion.outputs.version }}'
46
47 # comma (,) separated list
48 # of users to mention in the
49 # body of the Pull Request
50 USERS_TO_MENTION: hishamhm
51
52 steps:
53
54 - uses: actions/checkout@v4
55 with:
56 repository: ${{ env.TARGET_REPOSITORY }}
57 token: ${{ secrets.GH_ACTIONS_LUAROCKS_TOKEN }}
58 path: gh-actions-luarocks
59
60 - name: Create a new branch
61 working-directory: gh-actions-luarocks
62 run: git checkout -b ${{ env.NEW_BRANCH }}
63
64 - name: Set user name and email on commit
65 working-directory: gh-actions-luarocks
66 run: |
67 git config user.name "github-actions[bot]"
68 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
69
70 - name: Replace default version on action.yml
71 working-directory: gh-actions-luarocks
72 run: |
73 sed -e "s/default: \".*\"/default: \"${{ needs.SanitizeVersion.outputs.version }}\"/g" -i action.yml
74
75 - name: Stage changes
76 working-directory: gh-actions-luarocks
77 run: git add action.yml
78
79 - name: Commit changes
80 working-directory: gh-actions-luarocks
81 run: git commit "--message=${{ env.NEW_COMMIT_MSG }}"
82
83 - name: Print diff
84 working-directory: gh-actions-luarocks
85 run: git show
86
87 - name: Push changes
88 working-directory: gh-actions-luarocks
89 run: git push --set-upstream origin ${{ env.NEW_BRANCH }}
90
91 - name: Submit Pull Request
92 working-directory: gh-actions-luarocks
93 env:
94 GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_LUAROCKS_TOKEN }}
95 run: |
96 PR_BODY=""
97
98 IFS=',' read -ra reviewers <<< "${{ env.USERS_TO_MENTION }}"
99 for i in "${reviewers[@]}"; do
100 PR_BODY+="CC @${i} "
101 done
102
103 gh pr create \
104 --repo "${{ env.TARGET_REPOSITORY }}" \
105 --head ${{ env.NEW_BRANCH }} \
106 --title "${{ env.NEW_PR_TITLE }}" \
107 --body "${PR_BODY}" \ No newline at end of file