cmd #284
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: cmd | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
commands: | |
if: | | |
github.event.issue.pull_request && | |
(github.event.comment.body == '/sandbox') | |
runs-on: ubuntu-latest | |
name: Trigger command | |
env: | |
CMD_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Reaction in progress | |
uses: dkershner6/reaction-action@v2 | |
with: | |
token: ${{ env.CMD_TOKEN }} | |
reaction: "eyes" | |
- name: Fetch the last commit in the PR | |
id: sha | |
uses: actions/github-script@v7 | |
with: | |
result-encoding: string | |
script: | | |
const { owner, repo, number } = context.issue; | |
const pr = await github.pulls.get({ | |
owner, | |
repo, | |
pull_number: number, | |
}); | |
return pr.data.head.sha | |
- name: Show what commit hash we put in the mix | |
run: echo Working on the commit hash ${{ steps.sha.outputs.result }} | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ steps.sha.outputs.result }} | |
- name: Install NodeJS and NPM modules | |
uses: ./.github/actions/npm | |
- name: Install Railway CLI | |
if: github.event.comment.body == '/sandbox' | |
run: npm i -g @railway/cli | |
- name: Publish to sandbox | |
if: github.event.comment.body == '/sandbox' | |
run: railway up | |
env: | |
RAILWAY_TOKEN: ${{ secrets.RAILWAY_SANDBOX_TOKEN }} | |
- name: Send a rocket for success | |
uses: dkershner6/reaction-action@v2 | |
with: | |
token: ${{ env.CMD_TOKEN }} | |
reaction: "rocket" | |
- name: Send a thumbs down when failed | |
if: ${{ failure() }} | |
uses: dkershner6/reaction-action@v2 | |
with: | |
token: ${{ env.CMD_TOKEN }} | |
reaction: "-1" |