geodnet test fix (#806) #100
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: DevRel Notification | |
on: | |
push: | |
paths: | |
- examples/** | |
# - smartcontracts/** | |
- docs/** | |
pull_request: | |
paths: | |
- examples/** | |
# - smartcontracts/** | |
- docs/** | |
jobs: | |
notify: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Create or Update Issue | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const { owner, repo } = context.repo; | |
const issueTitle = 'Checkout new changes in Examples or Docs'; | |
// Determine if this was triggered by a push or pull request | |
const isPR = !!context.payload.pull_request; | |
const triggerLink = isPR | |
? context.payload.pull_request.html_url | |
: `${context.payload.repository.html_url}/commit/${context.sha}`; | |
const triggerDescription = isPR | |
? context.payload.pull_request.body || "No PR description provided." | |
: context.payload.head_commit.message || "No commit message provided."; | |
const triggerType = isPR ? "PR" : "commit"; | |
const issueBody = `@simonerom Changes were detected in the 'docs', 'examples', or 'smartcontracts' folder. | |
Please review the changes and update the docs portal if required. | |
The changes were triggered by this ${triggerType}: | |
[${triggerLink}](${triggerLink}) | |
_${triggerDescription}_`; | |
try { | |
const issues = await github.rest.issues.listForRepo({ | |
owner, | |
repo, | |
state: 'open', | |
labels: 'notification' | |
}); | |
if (issues.data.length === 0) { | |
// Create a new issue if no open issues with the label exist | |
await github.rest.issues.create({ | |
owner, | |
repo, | |
title: issueTitle, | |
body: issueBody, | |
labels: ['notification'] | |
}); | |
} else { | |
// Comment on the first open issue with the label | |
const issueNumber = issues.data[0].number; | |
await github.rest.issues.createComment({ | |
owner, | |
repo, | |
issue_number: issueNumber, | |
body: issueBody | |
}); | |
} | |
} catch (error) { | |
console.error('Error creating or updating issue:', error); | |
throw error; | |
} | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} # Using PAT_TOKEN if needed for permissions |