Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Update maven.yml #2

Merged
merged 8 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@ jobs:
run: |
echo "artifacts_path=$(realpath ../builds/${{ env.EVS_VERSION }})" >> $GITHUB_ENV
- name: 🧰 Create release zip
run: zip -r -q EVS-${{ env.EVS_VERSION }}.zip ${{ env.artifacts_path }}
run: |
find ${{ env.artifacts_path }} -type f \( -name ".gitignore" -o -name ".gitkeep" \) -exec rm -f {} \;
zip -r -q EVS-${{ env.EVS_VERSION }}.zip ${{ env.artifacts_path }}
- name: 📁 Archive artifacts
uses: actions/upload-artifact@v3
with:
name: EVS-build
path: ${{ env.artifacts_path }}
# I don't want the double-zip issue in artifact
# https://github.com/actions/upload-artifact#zipped-artifact-downloads
path: "${{ env.artifacts_path }}"
if-no-files-found: error
retention-days: 1
- uses: ncipollo/[email protected]
name: 🤖 Create release on Github
if: github.event.inputs.create_release && contains(github.ref, 'main')
Expand All @@ -67,4 +73,4 @@ jobs:
allowUpdates: "true"
tag: "${{ env.EVS_VERSION }}"
commit: "main"
name: "EVS-${{ env.EVS_VERSION }}"
name: "EVS-${{ env.EVS_VERSION }}"
78 changes: 38 additions & 40 deletions .github/workflows/pr-comment-artifact-url.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# pr-comment-artifact-url.yml
---
name: Comment Artifact URL on PR

# Credits to https://github.com/orgs/community/discussions/51403#discussioncomment-5515349
name: Comment Artifact URL on PR

on:
workflow_run:
Expand All @@ -14,65 +11,66 @@ on:
jobs:
comment-on-pr:
if: github.event.workflow_run.conclusion == 'success'
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:

- uses: 8BitJonny/[email protected]
id: PR
- name: Get Artifact URL & PR Info
if: steps.PR.outputs.pr_found == 'true'
env:
GITHUB_TOKEN: ${{ github.token }}
WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }}
run: |

PREVIOUS_JOB_ID=$(jq -r '.id' <<< "$WORKFLOW_RUN_EVENT_OBJ")
echo "Previous Job ID: $PREVIOUS_JOB_ID"
echo "PREVIOUS_JOB_ID=$PREVIOUS_JOB_ID" >> "$GITHUB_ENV"

ARTIFACT_URL=$(gh api "/repos/$OWNER/$REPO/actions/artifacts" \

SUITE_ID=$(jq -r '.check_suite_id' <<< "$WORKFLOW_RUN_EVENT_OBJ")
echo "Previous Suite ID: $SUITE_ID"
echo "SUITE_ID=$SUITE_ID" >> "$GITHUB_ENV"

ARTIFACT_ID=$(gh api "/repos/$OWNER/$REPO/actions/artifacts" \
--jq ".artifacts.[] |
select(.workflow_run.id==${PREVIOUS_JOB_ID}) |
select(.expired==false) |
.archive_download_url")

echo "ARTIFACT URL: $ARTIFACT_URL"
echo "ARTIFACT_URL=$ARTIFACT_URL" >> "$GITHUB_ENV"

.id")
echo "Artifact ID: $ARTIFACT_ID"
echo "ARTIFACT_ID=$ARTIFACT_ID" >> "$GITHUB_ENV"
PR_NUMBER=$(jq -r '.pull_requests[0].number' \
<<< "$WORKFLOW_RUN_EVENT_OBJ")

echo "PR Number: $PR_NUMBER"
echo "Pull request Number: $PR_NUMBER"
echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_ENV"

HEAD_SHA=$(jq -r '.pull_requests[0].head.sha' \
<<< "$WORKFLOW_RUN_EVENT_OBJ")

echo "Head sha: $HEAD_SHA"
echo "Head SHA: $HEAD_SHA"
echo "HEAD_SHA=$HEAD_SHA" >> "$GITHUB_ENV"

- name: Update Comment
if: steps.PR.outputs.pr_found == 'true'
env:
JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/\
runs/${{ env.PREVIOUS_JOB_ID }}"
HEAD_SHA: ${{ env.HEAD_SHA }}
JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ env.PREVIOUS_JOB_ID }}"
ARTIFACT_URL: "${{ github.server_url }}/${{ github.repository }}/suites/{{ env.SUITE_ID }}/artifacts/${{ env.ARTIFACT_ID }}"
HEAD_SHA: "${{ env.HEAD_SHA }}"
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ env.PR_NUMBER }}
body: |-
## Build Preview

[![badge]]($JOB_PATH)

You can find files attached to the below linked Workflow Run URL (Logs).

Please note that files only stay for around 90 days!

| Name | Link
--------------------------------------------------------------------
| Commit | ${{ env.HEAD_SHA }}

| Logs | ${{ env.JOB_PATH }}

| Jar Files | ${{ env. ARTIFACT_URL }}

[badge]: https://img.shields.io/badge/Build-Success!-3fb950?logo=github&style=for-the-badge
![badge]

Build Successful! You can find a link to the downloadable artifact below.

| Name | Link |
| -------- | ----------------------- |
| Commit | ${{ env.HEAD_SHA }} |
| Logs | ${{ env.JOB_PATH }} |
| Download | ${{ env.ARTIFACT_URL }} |

[badge]: https://img.shields.io/badge/Build_Success!-0d1117?style=for-the-badge&labelColor=3fb950&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZmZmZmZmIj48cGF0aCBkPSJNMjEuMDMgNS43MmEuNzUuNzUgMCAwIDEgMCAxLjA2bC0xMS41IDExLjVhLjc0Ny43NDcgMCAwIDEtMS4wNzItLjAxMmwtNS41LTUuNzVhLjc1Ljc1IDAgMSAxIDEuMDg0LTEuMDM2bDQuOTcgNS4xOTVMMTkuOTcgNS43MmEuNzUuNzUgMCAwIDEgMS4wNiAwWiI+PC9wYXRoPjwvc3ZnPg==