Chore/Acción automática al publicar una nueva oferta #12
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: Comment on PR | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
jobs: | |
comment_on_pr: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Check for changes in ofertas.ts | |
id: check_changes | |
run: | | |
git fetch origin main:main | |
# Find the merge base between main and the branch of the pull request | |
merge_base=$(git merge-base main HEAD) | |
if git diff --name-only $merge_base..HEAD | grep -q "pages/empleo/ofertas.ts"; then | |
echo "Changes found in ofertas.ts" | |
echo "::set-output name=changes::true" | |
else | |
echo "No changes in ofertas.ts" | |
echo "::set-output name=changes::false" | |
fi | |
- name: Comment on PR if there are changes in ofertas.ts | |
if: steps.check_changes.outputs.changes == 'true' | |
uses: actions/github-script@v4 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
try { | |
const message = `Hey there! It looks like there are new changes in 'ofertas.ts'. Please review the updates. Thank you!`; | |
github.issues.createComment({ | |
issue_number: context.payload.pull_request.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: message, | |
}); | |
} catch (error) { | |
console.error('Error posting comment:', error.message); | |
} |