build(deps-dev): bump the npm-development group across 1 directory with 12 updates #29
Workflow file for this run
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: Continuous Integration | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened, closed] | |
permissions: | |
contents: read | |
pull-requests: write | |
issues: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
cancel-in-progress: true | |
jobs: | |
deploy-preview: | |
name: GitHub Actions Test | |
runs-on: ubuntu-latest | |
if: ${{ github.event.action != 'closed' }} | |
steps: | |
- name: Checkout | |
id: checkout | |
uses: actions/checkout@v4 | |
- name: Test Local Action | |
id: test-action | |
uses: ./ | |
with: | |
railway_api_token: ${{ secrets.RAILWAY_API_TOKEN }} | |
project_id: ${{ secrets.RAILWAY_PROJECT_ID }} | |
environment_name: production | |
preview_environment_name: 'pr-${{ github.event.pull_request.number }}' | |
api_service_name: web | |
branch_name: ${{ github.head_ref }} | |
- name: Print Output | |
id: output | |
if: ${{ steps.test-action.outputs.service_domain != '' }} | |
run: echo "${{ steps.test-action.outputs.service_domain }}" | |
- name: Post or update deployment comment | |
if: ${{ steps.test-action.outputs.service_domain != '' }} | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const marker = '<!-- preview-comment -->'; // Unique marker to identify the comment | |
const { data: commits } = await github.rest.pulls.listCommits({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number, | |
per_page: 100 | |
}); | |
const latestCommit = commits[commits.length - 1]; | |
const latestCommitSha = latestCommit.sha.substring(0, 7); | |
const latestCommitAuthor = latestCommit.commit.author.name; | |
const { data: comments } = await github.rest.issues.listComments({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo | |
}); | |
const body = ` | |
${marker} <!-- This marker helps identify the comment for future updates --> | |
🚀 **Deployment success!** | |
- \`web\` deployed at [${{ steps.test-action.outputs.service_domain }}](https://${{ steps.test-action.outputs.service_domain }}) | |
--- | |
*commit: ${latestCommitSha}* | |
*author: ${latestCommitAuthor}* | |
`; | |
const existingComment = comments.find(comment => comment.body.includes(marker)); | |
if (existingComment) { | |
await github.rest.issues.updateComment({ | |
comment_id: existingComment.id, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: body | |
}); | |
core.info(`Updated comment ID: ${existingComment.id}`); | |
} else { | |
await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: body | |
}); | |
core.info('Created a new comment'); | |
} | |
cleanup: | |
runs-on: ubuntu-latest | |
if: | |
${{ github.event.pull_request.merged == true || github.event.action == | |
'closed' }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Cleanup Railway Environment | |
uses: ./ | |
with: | |
railway_api_token: ${{ secrets.RAILWAY_API_TOKEN }} | |
project_id: ${{ secrets.RAILWAY_PROJECT_ID }} | |
environment_name: production | |
preview_environment_name: 'pr-${{ github.event.pull_request.number }}' | |
branch_name: ${{ github.head_ref }} | |
cleanup: 'true' |