Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/eslint-9.11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ayungavis authored Dec 27, 2024
2 parents 9f6b151 + e44863d commit 9440328
Show file tree
Hide file tree
Showing 14 changed files with 696 additions and 395 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,3 @@ jobs:
- name: Test
id: npm-ci-test
run: npm run ci-test

test-action:
name: GitHub Actions Test
runs-on: ubuntu-latest

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:
preview-pr-${{ github.event.pull_request.number }}
api_service_name: web
branch_name: ${{ github.head_ref }}

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.service_domain }}"
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
uses: super-linter/super-linter/slim@v7
env:
DEFAULT_BRANCH: main
FILTER_REGEX_EXCLUDE: dist/**/*|example/**/*
FILTER_REGEX_EXCLUDE: dist/**/*|example/**/*|README.md
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_ALL_CODEBASE: true
VALIDATE_JAVASCRIPT_STANDARD: false
Expand Down
116 changes: 116 additions & 0 deletions .github/workflows/test-action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
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@v7
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'
Loading

0 comments on commit 9440328

Please sign in to comment.