Skip to content

Commit 0bf5ef5

Browse files
authored
Merge pull request #138 from git-for-windows/drop-pacman-package-from-sdks
Add a GitHub workflow to uninstall packages from the SDKs
2 parents 3388926 + 477b501 commit 0bf5ef5

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Drop Pacman package from SDKs
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
package:
7+
description: 'The Pacman package to drop from the SDKs'
8+
required: true
9+
commit-message:
10+
description: 'Additional text to add to the commit message'
11+
type: string
12+
required: true
13+
14+
env:
15+
PACKAGE: ${{ github.event.inputs.package }}
16+
COMMIT_MESSAGE: ${{ github.event.inputs.commit-message }}
17+
GIT_CONFIG_PARAMETERS: "'user.name=Git for Windows Build Agent' '[email protected]' 'windows.sdk64.path=${{ github.workspace }}' 'windows.sdk32.path=' 'http.sslbackend=schannel' 'core.autocrlf=false' 'checkout.workers=56'"
18+
HOME: "${{ github.workspace }}\\home\\git-ci"
19+
MSYSTEM: MSYS
20+
21+
jobs:
22+
drop-pacman-package:
23+
strategy:
24+
matrix:
25+
sdk: [git-sdk-64, git-sdk-arm64, git-sdk-32]
26+
runs-on: ${{ matrix.sdk == 'git-sdk-arm64' && 'windows-11-arm' || 'windows-latest' }}
27+
steps:
28+
- name: obtain installation access token
29+
uses: actions/create-github-app-token@v2
30+
id: sdk-repo-token
31+
with:
32+
app-id: ${{ secrets.GH_APP_ID }}
33+
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
34+
owner: ${{ github.repository_owner }}
35+
repositories: ${{ matrix.sdk }}
36+
- name: clone ${{ matrix.sdk }}
37+
uses: actions/checkout@v5
38+
with:
39+
persist-credentials: true
40+
repository: ${{ github.repository_owner }}/${{ matrix.sdk }}
41+
token: ${{ steps.sdk-repo-token.outputs.token }}
42+
- name: use the SDK's Bash and git.exe
43+
run: "usr\\bin\\bash.exe -lc 'cygpath -aw /usr/bin >>$GITHUB_PATH && cygpath -aw /cmd >>$GITHUB_PATH'"
44+
- name: Remove ${{ env.PACKAGE }}
45+
shell: bash
46+
run: |
47+
set -x &&
48+
. /etc/profile &&
49+
# Log the output also to a file so that it can be inserted into the commit message later
50+
cygpath -aw /tmp/commit-message.txt &&
51+
(
52+
set -x &&
53+
pacman -Rns --noconfirm $PACKAGE;
54+
echo $? >/tmp/exit.status
55+
) 2>&1 |
56+
tee -a /tmp/commit-message.txt &&
57+
exit $(cat /tmp/exit.status)
58+
- name: commit & open PR
59+
shell: bash
60+
run: |
61+
set -x &&
62+
branch="drop-$PACKAGE-$(date +%s)" &&
63+
git switch -c "$branch" &&
64+
git add -A . &&
65+
if git diff --cached --quiet; then
66+
echo "::warning::${{ matrix.sdk }}: no changes to commit!"
67+
exit 0
68+
fi &&
69+
commit_message="Drop package '$PACKAGE'
70+
71+
$COMMIT_MESSAGE
72+
73+
Here is the output of the command that was run in
74+
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}:
75+
76+
$(cat /tmp/commit-message.txt)" &&
77+
git commit -m "$commit_message" &&
78+
git push origin "$branch" &&
79+
(
80+
GH_TOKEN="${{ steps.sdk-repo-token.outputs.token }}" \
81+
gh pr create \
82+
--fill \
83+
--head "$branch" \
84+
--base main 2>&1;
85+
echo $? >/tmp/exit.status
86+
) |
87+
tee -a /tmp/pr-create-output.txt &&
88+
test 0 = $(cat /tmp/exit.status) &&
89+
sed -n 's/.*\(http[^ ]*\).*/::notice::Opened PR \1/p' /tmp/pr-create-output.txt

0 commit comments

Comments
 (0)