Skip to content

Commit 77c076d

Browse files
committed
add PR snapshots
1 parent 4df098f commit 77c076d

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,35 @@ jobs:
2323
env:
2424
GITHUB_USER_NAME: ${{ github.actor }}
2525
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
27+
snapshot:
28+
name: Publish snapshot
29+
runs-on: ubuntu-22.04
30+
timeout-minutes: 10
31+
needs: test
32+
if: github.event_name == 'pull_request'
33+
steps:
34+
- name: Set Version
35+
run: sed -i 's|<version>BUILD-SNAPSHOT</version>|<version>${{ github.event.pull_request.number }}-SNAPSHOT</version>|g' pom.xml
36+
- run: >-
37+
./mvnw
38+
-s $GITHUB_WORKSPACE/.github/workflows/maven-settings.xml
39+
--batch-mode
40+
-DskipTests=true
41+
deploy
42+
env:
43+
GITHUB_USER_NAME: ${{ github.actor }}
44+
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
46+
remove-snapshot:
47+
name: Remove Snapshot
48+
runs-on: ubuntu-22.04
49+
timeout-minutes: 10
50+
if: github.event_name == 'pull_request' && github.event.action == 'closed'
51+
steps:
52+
- name: Authenticate with GitHub Packages
53+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_USER_NAME --password-stdin
54+
- name: Remove snapshot version from repository
55+
run: |
56+
curl -X DELETE -u ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} \
57+
https://maven.pkg.github.com/OWNER/REPOSITORY/com/example/myartifact/${{ github.event.pull_request.number }}-SNAPSHOT/

0 commit comments

Comments
 (0)