-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add basic ci and fix formatting
- Loading branch information
1 parent
0b4d48b
commit aa3fec3
Showing
8 changed files
with
299 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Environment Setup | ||
description: 'Setup PNPM and Node' | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Setup PNPM | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9.1.1 | ||
- name: Set up NodeJS v20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
registry-url: 'https://registry.npmjs.org' | ||
cache: 'pnpm' | ||
- name: Install npm modules | ||
shell: bash | ||
run: pnpm install --ignore-scripts --frozen-lockfile |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Repo Metadata | ||
description: 'Generate sha8 of latest commit and next release version' | ||
inputs: | ||
github_token: | ||
description: 'secrets.GITHUB_TOKEN' | ||
required: true | ||
outputs: | ||
sha8: | ||
description: 'Latest commit sha8' | ||
value: ${{ steps.slug.outputs.sha8 }} | ||
repo_slug: | ||
description: 'Latest commit sha8' | ||
value: ${{ steps.repo_slug.outputs.result }} | ||
next_version: | ||
description: 'Next release version' | ||
value: ${{ steps.preview_release.outputs.next_version }} | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Get last commit short SHA | ||
shell: bash | ||
id: slug | ||
run: echo "sha8=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT | ||
- name: Sanitize repo owner slug | ||
uses: actions/github-script@v6 | ||
id: repo_slug | ||
with: | ||
result-encoding: string | ||
script: return `ghcr.io/${context.repo.owner.toLowerCase()}/${context.repo.repo.toLowerCase()}` | ||
- name: Checkout branch | ||
shell: bash | ||
run: git checkout $GITHUB_HEAD_REF | ||
- name: Set up NodeJS (LTS) | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 'lts/*' | ||
- name: Install dependencies | ||
shell: bash | ||
run: | | ||
npm install -g semantic-release@23 | ||
npm install -g @semantic-release/changelog | ||
- name: Preview semantic-release | ||
shell: bash | ||
id: preview_release | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.github_token }} | ||
run: | | ||
export NEXT_VERSION=$(unset GITHUB_ACTIONS && npx semantic-release --dry-run --no-ci --branches main | grep 'The next release version is' | sed -E 's/.* ([[:digit:].]+)$/\1/') | ||
echo "$NEXT_VERSION" | ||
echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: PR Commit | ||
on: | ||
pull_request: | ||
branches: [main] | ||
env: | ||
WORKSPACE_ROOT: . | ||
CACHE_SUFFIX: c # cache busting | ||
|
||
# Cancel redundant workflow runs | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
pre_job: | ||
name: Run Workflow? | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
should_skip: ${{ steps.skip_check.outputs.should_skip }} | ||
steps: | ||
- id: skip_check | ||
uses: fkirc/skip-duplicate-actions@master | ||
with: | ||
concurrent_skipping: 'never' | ||
skip_after_successful_duplicate: 'true' | ||
# Changes to paths must be synced with pr-merge*.yml | ||
paths: '[".github/workflows/pr-commit.yml", "web/**", "*"]' | ||
paths_ignore: '["**/Readme.md"]' | ||
|
||
check-format: | ||
needs: pre_job | ||
if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
name: Format, Lint, Unit Test | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout code into workspace directory | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: ./.github/actions/env-setup | ||
- name: Check code format | ||
run: npm run format:check | ||
- name: Lint source code | ||
if: success() || failure() | ||
run: npm run lint | ||
- name: Lint style | ||
if: success() || failure() | ||
run: npm run lint:style | ||
|
||
build-apps: | ||
needs: pre_job | ||
if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
name: Build Apps | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout code into workspace directory | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: ./.github/actions/env-setup | ||
- name: Build web app | ||
run: npm run prod:web:build |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
name: PR Merge (main) | ||
|
||
on: | ||
# push: | ||
# branches: [main] | ||
repository_dispatch: | ||
types: [trigger-workflow] | ||
|
||
env: | ||
WORKSPACE_ROOT: . | ||
ENVIRONMENT: stg | ||
CACHE_SUFFIX: c # cache busting | ||
|
||
# Cancel redundant workflow runs | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
pre_job: | ||
name: Run Workflow? | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
should_skip: ${{ steps.skip_check.outputs.should_skip }} | ||
steps: | ||
- id: skip_check | ||
uses: fkirc/skip-duplicate-actions@master | ||
with: | ||
concurrent_skipping: 'never' | ||
skip_after_successful_duplicate: 'true' | ||
# Changes to paths must be synced with pr-merge*.yml | ||
paths: '[".github/workflows/pr-commit.yml", "web/**", "backend/**", "*"]' | ||
paths_ignore: '["**/README.md", "skaffold*.yaml"]' | ||
|
||
repo-metadata: | ||
name: Get repo metadata | ||
runs-on: ubuntu-latest | ||
outputs: | ||
next_version: ${{ steps.meta.outputs.next_version }} | ||
sha8: ${{ steps.meta.outputs.sha8 }} | ||
repo_slug: ${{ steps.meta.outputs.repo_slug }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
- id: meta | ||
uses: ./.github/actions/repo-metadata | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
build-apps: | ||
needs: pre_job | ||
if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
name: Build Apps | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout code into workspace directory | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: ./.github/actions/env-setup | ||
- name: Build web app | ||
run: npm run prod:web:build | ||
|
||
build-docker-web-stg: | ||
needs: [pre_job, repo-metadata] | ||
if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
name: Web Staging Image | ||
runs-on: ubuntu-22.04 | ||
env: | ||
APP_NAME: web | ||
BRANCH_NAME: main | ||
steps: | ||
- name: Checkout code into workspace directory | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{github.actor}} | ||
password: ${{secrets.GITHUB_TOKEN}} | ||
- name: Build and push staging docker image | ||
id: docker_build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ${{env.WORKSPACE_ROOT}} | ||
build-args: | | ||
"LAST_COMMIT_SHA=${{needs.repo-metadata.outputs.sha8}}" | ||
"RELEASE_VERSION=${{needs.repo-metadata.outputs.next_version}}" | ||
push: true | ||
file: ${{env.WORKSPACE_ROOT}}/apps/${{env.APP_NAME}}/Dockerfile | ||
target: stg | ||
tags: | | ||
${{needs.repo-metadata.outputs.repo_slug}}/${{env.ENVIRONMENT}}/${{env.APP_NAME}}:${{env.BRANCH_NAME}}-${{needs.repo-metadata.outputs.sha8}}-${{github.run_number}} | ||
${{needs.repo-metadata.outputs.repo_slug}}/${{env.ENVIRONMENT}}/${{env.APP_NAME}}:latest |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: PR Merge (prod) | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
repository_dispatch: | ||
types: [trigger-workflow] | ||
|
||
env: | ||
WORKSPACE_ROOT: . | ||
ENVIRONMENT: prod | ||
|
||
# Cancel redundant workflow runs | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
pre_job: | ||
# needs: fast_forward_job | ||
name: Run Workflow? | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
should_skip: ${{ steps.skip_check.outputs.should_skip }} | ||
steps: | ||
- id: skip_check | ||
if: ${{ github.event_name != 'workflow_dispatch' }} | ||
uses: fkirc/skip-duplicate-actions@master | ||
with: | ||
concurrent_skipping: 'never' | ||
skip_after_successful_duplicate: 'true' | ||
# Changes to paths must be synced with pr-merge*.yml | ||
paths: '[".github/workflows/pr-commit.yml", "web/**", "backend/**", "*"]' | ||
paths_ignore: '["**/README.md", "skaffold*.yaml"]' | ||
|
||
repo-metadata: | ||
needs: pre_job | ||
if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
name: Get repo metadata | ||
runs-on: ubuntu-latest | ||
outputs: | ||
next_version: ${{ steps.meta.outputs.next_version }} | ||
sha8: ${{ steps.meta.outputs.sha8 }} | ||
repo_slug: ${{ steps.meta.outputs.repo_slug }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
- id: meta | ||
uses: ./.github/actions/repo-metadata | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
build-apps: | ||
needs: pre_job | ||
if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
name: Build Apps | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout code into workspace directory | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: ./.github/actions/env-setup | ||
- name: Build web app | ||
run: npm run prod:web:build |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
|
||
export { default as Burger } from './Burger.vue' |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './simple-i18n' | ||
export * from './simple-i18n' |