Skip to content

Commit 0fd05de

Browse files
authored
chore: Workflow maintenance (#344)
- Use auto-generated GitHub tokens in all workflows Signed-off-by: Esta Nagy <nagyesta@gmail.com>
1 parent 4cfb3dd commit 0fd05de

File tree

3 files changed

+34
-27
lines changed

3 files changed

+34
-27
lines changed

.github/workflows/gradle-ci.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# This workflow uses actions that are not certified by GitHub.
2-
# They are provided by a third-party and are governed by
3-
# separate terms of service, privacy policy, and support
4-
# documentation.
5-
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6-
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
7-
81
name: Gradle CI
92

103
on:

.github/workflows/gradle.yml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# This workflow uses actions that are not certified by GitHub.
2-
# They are provided by a third-party and are governed by
3-
# separate terms of service, privacy policy, and support
4-
# documentation.
5-
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6-
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
7-
81
name: Gradle
92

103
on:
@@ -20,15 +13,19 @@ permissions:
2013

2114
jobs:
2215
build:
16+
name: Build
2317
runs-on: ubuntu-latest
2418
permissions:
2519
contents: write
20+
packages: write
21+
outputs:
22+
tag_name: ${{ steps.read-tag-name.outputs.RELEASE_TAG_NAME }}
2623
steps:
24+
# Set up the build environment
2725
- name: Checkout
2826
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2927
with:
3028
fetch-depth: 0
31-
token: ${{ secrets.PUBLISH_KEY }}
3229
- name: Set up JDK 25
3330
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
3431
with:
@@ -43,29 +40,43 @@ jobs:
4340
- name: Setup Gradle
4441
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
4542
- name: Build with Gradle
46-
run: ./gradlew clean buildDocker
43+
run: ./gradlew clean printVersion buildDocker
4744
- name: Docker Login
4845
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
4946
with:
5047
username: ${{ secrets.DOCKERHUB_USERNAME }}
5148
password: ${{ secrets.DOCKERHUB_TOKEN }}
52-
- name: Tag and publish using Gradle
53-
env:
54-
ORG_GRADLE_PROJECT_githubUser: ${{ secrets.PUBLISH_USER_NAME }}
55-
ORG_GRADLE_PROJECT_githubToken: ${{ secrets.PUBLISH_KEY }}
56-
run: ./gradlew tagVersion buildDockerPush
5749
- name: Read tag name
5850
id: read-tag-name
5951
run: |
6052
echo "RELEASE_TAG_NAME=$(cat ./build/version)" >> "$GITHUB_OUTPUT"
61-
- name: Generate release
53+
- name: Tag version
54+
run: |
55+
git config --global user.name 'Esta Nagy'
56+
git config --global user.email 'nagyesta@gmail.com'
57+
git tag ${{ steps.read-tag-name.outputs.RELEASE_TAG_NAME }}
58+
git push origin ${{ steps.read-tag-name.outputs.RELEASE_TAG_NAME }}
59+
- name: Publish with Gradle
60+
run: ./gradlew buildDockerPush
61+
62+
create-release:
63+
name: Create Release
64+
runs-on: ubuntu-latest
65+
needs: build
66+
permissions:
67+
contents: write
68+
steps:
69+
- name: Create release
6270
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
71+
env:
72+
TAG_NAME: ${{needs.build.outputs.tag_name }}
6373
with:
6474
script: |
6575
github.rest.repos.createRelease({
6676
owner: context.repo.owner,
6777
repo: context.repo.repo,
68-
tag_name: "${{ steps.read-tag-name.outputs.RELEASE_TAG_NAME }}",
78+
tag_name: "${{ env.TAG_NAME }}",
6979
generate_release_notes: true,
7080
draft: false
7181
});
82+

.github/workflows/pr-labeler.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ permissions: read-all
55

66
jobs:
77
pr-labeler:
8+
name: Label PR
89
runs-on: ubuntu-latest
10+
permissions:
11+
pull-requests: write
912
steps:
1013
- name: Checkout
1114
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1215
with:
1316
fetch-depth: 0
14-
token: ${{ secrets.PUBLISH_KEY }}
1517
- name: Get branch name
1618
id: get-branch-name
1719
env:
@@ -26,10 +28,12 @@ jobs:
2628
- name: Convert to label
2729
id: convert-to-label
2830
run: |
29-
if [[ "${{ steps.get-branch-name.outputs.BRANCH_NAME }}" == feature/* ]]; then
31+
if [[ "${{ steps.get-branch-name.outputs.BRANCH_NAME }}" == feat/* ]]; then
3032
echo "LABEL_NAME=enhancement" >> $GITHUB_OUTPUT
31-
elif [[ "${{ steps.get-branch-name.outputs.BRANCH_NAME }}" == feat/* ]]; then
33+
elif [[ "${{ steps.get-branch-name.outputs.BRANCH_NAME }}" == feature/* ]]; then
3234
echo "LABEL_NAME=enhancement" >> $GITHUB_OUTPUT
35+
elif [[ "${{ steps.get-branch-name.outputs.BRANCH_NAME }}" == fix/* ]]; then
36+
echo "LABEL_NAME=bug" >> $GITHUB_OUTPUT
3337
elif [[ "${{ steps.get-branch-name.outputs.BRANCH_NAME }}" == bugfix/* ]]; then
3438
echo "LABEL_NAME=bug" >> $GITHUB_OUTPUT
3539
elif [[ "${{ steps.get-branch-name.outputs.BRANCH_NAME }}" == bug/* ]]; then
@@ -52,7 +56,6 @@ jobs:
5256
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
5357
if: ${{ steps.convert-to-label.outputs.LABEL_NAME != 'none' }}
5458
with:
55-
github-token: ${{ secrets.PUBLISH_KEY }}
5659
script: |
5760
github.rest.issues.addLabels({
5861
issue_number: ${{ github.event.pull_request.number }},

0 commit comments

Comments
 (0)