🐳docker: update Dockerfile #120
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: Test | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
pull_request_target: | |
paths: | |
- "app/**" | |
- "public/**" | |
- "test/**" | |
- ".dockerignore" | |
- "bun.lockb" | |
- "Dockerfile" | |
- "package.json" | |
- "*config.*" | |
push: | |
paths: | |
- "app/**" | |
- "public/**" | |
- "test/**" | |
- ".dockerignore" | |
- "bun.lockb" | |
- "Dockerfile" | |
- "package.json" | |
- "*config.*" | |
workflow_dispatch: | |
permissions: | |
pull-requests: write | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: canary | |
- name: Install dependencies | |
run: bun i | |
- name: Test app | |
run: | | |
bun test:app &> >(tee -p test.log) || echo STATUS=$? >> $GITHUB_ENV | |
{ | |
echo 'RESULT<<EOF' | |
cat test.log | |
echo EOF | |
} >> $GITHUB_ENV | |
- name: Create test comment | |
if: github.event_name == 'pull_request_target' && env.STATUS == 1 | |
env: | |
ACTOR: ${{ github.actor }} | |
REPO: ${{ github.repository }} | |
RUN_ID: ${{ github.run_id }} | |
SHA: ${{ github.event.pull_request.head.sha }} | |
WORKFLOW_REF: ${{ github.workflow_ref }} | |
run: | | |
{ | |
echo 'TEST_COMMENT<<EOF' | |
echo '# ❌Test Failed' | |
echo "@$ACTOR, your commit $SHA failed the test." | |
echo '<details>' | |
echo '<summary><strong>Show Test Log</strong></summary>' | |
echo '' | |
echo "\`\`\`shell" | |
echo "$RESULT" | |
echo "\`\`\`" | |
echo '' | |
echo '</details>' | |
echo '' | |
echo "👀[View in Actions](https://github.com/$REPO/actions/runs/$RUN_ID)" | |
echo "<!-- generated-comment [Test]($WORKFLOW_REF) -->" | |
echo 'EOF' | |
} >> $GITHUB_ENV | |
- name: Add a test comment | |
if: github.event_name == 'pull_request_target' && env.STATUS == 1 | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { data: comments } = await github.rest.issues.listComments({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
}) | |
const testComment = comments.find(comment => { | |
return comment.user.type === 'Bot' && comment.body.includes('# ❌Test Failed') | |
}) | |
if (testComment) { | |
github.rest.issues.deleteComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: testComment.id, | |
}) | |
} | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: process.env.TEST_COMMENT | |
}) | |
- name: Add a Fixed comment | |
if: github.event_name == 'pull_request_target' && env.STATUS == 0 | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { data: comments } = await github.rest.issues.listComments({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
}) | |
const testComment = comments.find(comment => { | |
return comment.user.type === 'Bot' && comment.body.includes('# ❌Test Failed') | |
}) | |
const body = `# ✅Test Passed | |
Failed tests were fixed. | |
<!-- generated-comment [Test]($WORKFLOW_REF) -->` | |
if (testComment) { | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: body | |
}) | |
} | |
- name: Fail if test failed | |
if: env.STATUS == 1 | |
run: exit 1 |