Skip to content

Commit a11ffe0

Browse files
committed
feat: add workflow to label pull requests with changed release version
1 parent b4179fa commit a11ffe0

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Adicionar label de release quando versão for alterada
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
jobs:
8+
verificar-versao:
9+
runs-on: ubuntu-latest
10+
11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
15+
steps:
16+
- name: Fazer checkout do código do PR
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Instalar xmllint
22+
run: sudo apt-get update && sudo apt-get install -y libxml2-utils
23+
24+
- name: Obter versão base (branch de destino)
25+
run: |
26+
git fetch origin ${{ github.event.pull_request.base.ref }}
27+
git checkout origin/${{ github.event.pull_request.base.ref }}
28+
VERSION_BASE=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='version']/text()" pom.xml)
29+
echo "VERSION_BASE=$VERSION_BASE" >> $GITHUB_ENV
30+
31+
- name: Obter versão do head (branch do PR)
32+
run: |
33+
git checkout ${{ github.event.pull_request.head.ref }}
34+
VERSION_HEAD=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='version']/text()" pom.xml)
35+
echo "VERSION_HEAD=$VERSION_HEAD" >> $GITHUB_ENV
36+
37+
- name: Comparar versões
38+
id: compare
39+
run: |
40+
echo "Versão base: $VERSION_BASE"
41+
echo "Versão do PR: $VERSION_HEAD"
42+
if [ "$VERSION_BASE" != "$VERSION_HEAD" ]; then
43+
echo "changed=true" >> $GITHUB_OUTPUT
44+
else
45+
echo "changed=false" >> $GITHUB_OUTPUT
46+
fi
47+
48+
- name: Adicionar label 'release' se versão mudou
49+
if: steps.compare.outputs.changed == 'true'
50+
uses: actions/github-script@v7
51+
with:
52+
script: |
53+
github.rest.issues.addLabels({
54+
issue_number: context.payload.pull_request.number,
55+
owner: context.repo.owner,
56+
repo: context.repo.repo,
57+
labels: ['release']
58+
})

0 commit comments

Comments
 (0)