Browse Source

Actions: Use different plugin to create comment

pull/245/head
weisj 3 years ago
parent
commit
485934b17e
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 53
      .github/workflows/branch-snapshot.yml
  2. 2
      build.gradle.kts

53
.github/workflows/branch-snapshot.yml

@ -1,7 +1,7 @@
name: Build branch SNAPSHOT name: Build branch SNAPSHOT
on: on:
pull_request: pull_request_target:
types: [opened] types: [opened]
issue_comment: issue_comment:
types: [created] types: [created]
@ -27,26 +27,49 @@ jobs:
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: 8 java-version: 8
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Publish - name: Publish
if: steps.check.outputs.triggered == 'true' if: steps.check.outputs.triggered == 'true'
env: env:
PROPS_RELEASE: "-Prc=1 -Pgh -Prelease=false -PskipJavadoc -PskipAutostyle -PfailIfLibraryMissing -PuseBranchSnapshotName=true" PROPS_RELEASE: "-Prc=1 -Pgh -Prelease=false -PskipJavadoc -PskipAutostyle -PfailIfLibraryMissing -snapshotName=${{ steps.extract_branch.outputs.branch }}"
PROPS_GIT: "-PghGitSourceUsername=${{ secrets.GH_GIT_USERNAME }} -PghGitSourcePassword=${{ secrets.GITHUB_TOKEN }}" PROPS_GIT: "-PghGitSourceUsername=${{ secrets.GH_GIT_USERNAME }} -PghGitSourcePassword=${{ secrets.GITHUB_TOKEN }}"
PROPS_NEXUS: "-PghNexusUsername=${{ secrets.GH_NEXUS_USERNAME }} -PghNexusPassword=${{ secrets.GH_NEXUS_PASSWORD }}" PROPS_NEXUS: "-PghNexusUsername=${{ secrets.GH_NEXUS_USERNAME }} -PghNexusPassword=${{ secrets.GH_NEXUS_PASSWORD }}"
PROPS_SIGNING: "-PuseInMemoryKey=true -Psigning.inMemoryKey=${{ secrets.IN_MEMORY_KEY }} -Psigning.password=${{ secrets.SIGNING_PASSWORD }}" PROPS_SIGNING: "-PuseInMemoryKey=true -Psigning.inMemoryKey=${{ secrets.IN_MEMORY_KEY }} -Psigning.password=${{ secrets.SIGNING_PASSWORD }}"
PROPS_GITHUB: "-PgithubAccessToken=${{ secrets.GITHUB_TOKEN }}" PROPS_GITHUB: "-PgithubAccessToken=${{ secrets.GITHUB_TOKEN }}"
run: ./gradlew prepareVote $(echo $PROPS_RELEASE $PROPS_GIT $PROPS_NEXUS $PROPS_SIGNING $PROPS_GITHUB) -x test run: ./gradlew prepareVote $(echo $PROPS_RELEASE $PROPS_GIT $PROPS_NEXUS $PROPS_SIGNING $PROPS_GITHUB) -x test
- name: Add comment to PR - name: Find Comment
if: steps.check.outputs.triggered == 'true' if: steps.check.outputs.triggered == 'true'
env: uses: peter-evans/find-comment@v1
URL: ${{ github.event.issue.comments_url }} id: fc
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with:
COMMENT_CONTENT: | issue-number: ${{ github.event.pull_request.number }}
'{ "body": "This PR has been deployed as a snasphot version. Try it out using:\r\n````kotlin\r\nrepositories {\r\n maven {\r\n url = uri(\"https:\/\/oss.sonatype.org\/content\/repositories\/snapshots\/\")\r\n }\r\n}\r\n\r\nconfigurations.all {\r\n resolutionStrategy.cacheChangingModulesFor(0, \\\"seconds\\\")\r\n}\r\n\r\ndependencies {\r\n implementation(\"com.github.weisj:darklaf-core-${{ env.GITHUB_HEAD_REF }}:latest.integration\")\r\n}\r\n````" }' comment-author: 'github-actions[bot]'
run: | body-includes: "[Snapshot Created]"
curl \ - name: Create comment
-X POST \ if: steps.check.outputs.triggered == 'true'
$URL \ uses: peter-evans/create-or-update-comment@v1
-H "Content-Type: application/json" \ with:
-H "Authorization: token $GITHUB_TOKEN" \ comment-id: ${{ steps.fc.outputs.comment-id }}
--data $COMMENT_CONTENT issue-number: ${{ github.event.pull_request.number }}
body: |
[Snapshot Created]
This PR has been deployed as a snasphot version. Try it out using:
````kotlin
repositories {
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor(0, \"seconds\")
}
dependencies {
implementation("com.github.weisj:darklaf-core-${{ env.GITHUB_HEAD_REF }}:latest.integration")
}
````
edit-mode: replace

2
build.gradle.kts

@ -23,7 +23,7 @@ val enableGradleMetadata by props()
val skipAutostyle by props(false) val skipAutostyle by props(false)
val isRelease = project.stringProperty("release").toBool() val isRelease = project.stringProperty("release").toBool()
val snapshotName = if (project.props.bool("useBranchSnapshotName")) { val snapshotName = if (project.props.bool("useBranchSnapshotName")) {
println("Using branch as snashotName ${System.getenv("GITHUB_HEAD_REF")} (${grgit.branch.current()?.name ?: ""})") println("Using branch as snapshotName ${System.getenv("GITHUB_HEAD_REF")} (${grgit.branch.current()?.name ?: ""})")
System.getenv("GITHUB_HEAD_REF") ?: grgit.branch.current()?.name System.getenv("GITHUB_HEAD_REF") ?: grgit.branch.current()?.name
} else { } else {
project.stringProperty("snapshotName") project.stringProperty("snapshotName")

Loading…
Cancel
Save