adding github workflows
This commit is contained in:
69
.github/workflows/api_build.yaml
vendored
Normal file
69
.github/workflows/api_build.yaml
vendored
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
name: 'API Build'
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
environment_name:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
version_number:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: ${{ inputs.environment_name }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
sparse-checkout: |
|
||||||
|
api
|
||||||
|
|
||||||
|
- uses: pnpm/action-setup@v4
|
||||||
|
name: Install pnpm
|
||||||
|
with:
|
||||||
|
version: 10
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: Install Nest CLI
|
||||||
|
run: |
|
||||||
|
npm install -g @nestjs/cli
|
||||||
|
|
||||||
|
- name: 'Setup Node'
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ vars.NODE_VERSION }}
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
pnpm --filter api build
|
||||||
|
|
||||||
|
- name: Deploy
|
||||||
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
run: |
|
||||||
|
pnpm --filter api --prod deploy ./.prod/api
|
||||||
|
|
||||||
|
- name: Log into Docker Hub
|
||||||
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Setup Docker Buildx
|
||||||
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and push to registry
|
||||||
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: noahspan/flying-api:${{ inputs.version_number }}
|
||||||
|
context: .
|
||||||
|
target: api
|
||||||
70
.github/workflows/app_build.yaml
vendored
Normal file
70
.github/workflows/app_build.yaml
vendored
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
name: 'App Build'
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
environment_name:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
version_number:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
env:
|
||||||
|
VITE_API_URL: ${{ vars.VITE_API_URL }}
|
||||||
|
VITE_CLIENT_ID: ${{ vars.VITE_CLIENT_ID }}
|
||||||
|
VITE_TENANT_ID: ${{ vars.VITE_TENANT_ID }}
|
||||||
|
VITE_REDIRECT_URL: ${{ vars.VITE_REDIRECT_URL }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: ${{ inputs.environment_name }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
sparse-checkout: |
|
||||||
|
app
|
||||||
|
|
||||||
|
- uses: pnpm/action-setup@v4
|
||||||
|
name: Install pnpm
|
||||||
|
with:
|
||||||
|
version: 10
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: 'Setup Node'
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ vars.NODE_VERSION }}
|
||||||
|
|
||||||
|
- name: Install
|
||||||
|
run: |
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
pnpm --filter app build
|
||||||
|
|
||||||
|
- name: Deploy
|
||||||
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
run: |
|
||||||
|
pnpm --filter app --prod deploy ./.prod/app
|
||||||
|
|
||||||
|
- name: Setup Docker Buildx
|
||||||
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log into Docker Hub
|
||||||
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push to registry
|
||||||
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: noahspan/flying-app:${{ inputs.version_number }}
|
||||||
|
context: .
|
||||||
|
target: app
|
||||||
28
.github/workflows/changes.yaml
vendored
Normal file
28
.github/workflows/changes.yaml
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
name: Changes
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
outputs:
|
||||||
|
api:
|
||||||
|
value: ${{ jobs.changes.outputs.api }}
|
||||||
|
app:
|
||||||
|
value: ${{ jobs.changes.outputs.app }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
changes:
|
||||||
|
name: filter
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
api: ${{ steps.filter.outputs.api }}
|
||||||
|
app: ${{ steps.filter.outputs.app }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- uses: dorny/paths-filter@v3
|
||||||
|
id: filter
|
||||||
|
with:
|
||||||
|
initial-fetch-depth: 2
|
||||||
|
filters: |
|
||||||
|
api:
|
||||||
|
- 'api/**'
|
||||||
|
app:
|
||||||
|
- 'app/**'
|
||||||
35
.github/workflows/deploy.yaml
vendored
Normal file
35
.github/workflows/deploy.yaml
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
name: Deploy
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
app_name:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
environment_name:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
version_number:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
|
contents: read
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: ${{ inputs.environment_name }}
|
||||||
|
steps:
|
||||||
|
- name: Log in to Azure
|
||||||
|
uses: azure/login@v2
|
||||||
|
with:
|
||||||
|
client-id: ${{ vars.VITE_CLIENT_ID }}
|
||||||
|
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
||||||
|
tenant-id: ${{ vars.VITE_TENANT_ID }}
|
||||||
|
|
||||||
|
- name: Azure CLI script
|
||||||
|
uses: azure/cli@v2
|
||||||
|
with:
|
||||||
|
azcliversion: latest
|
||||||
|
inlineScript: |
|
||||||
|
az containerapp update --name ${{ inputs.app_name }}-${{ inputs.environment_name }} --resource-group noahspan-flying --image docker.io/noahspan/${{ inputs.app_name }}:${{ inputs.version_number }}
|
||||||
55
.github/workflows/main.yaml
vendored
Normal file
55
.github/workflows/main.yaml
vendored
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
name: Main
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
changes:
|
||||||
|
uses: ./.github/workflows/changes.yaml
|
||||||
|
|
||||||
|
build-api:
|
||||||
|
if: ${{ needs.changes.outputs.api == 'true' }}
|
||||||
|
name: build-api
|
||||||
|
needs:
|
||||||
|
- changes
|
||||||
|
uses: ./.github/workflows/api_build.yaml
|
||||||
|
with:
|
||||||
|
environment_name: test
|
||||||
|
version_number: ${{ github.run_id }}
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
deploy-api:
|
||||||
|
name: deploy-api
|
||||||
|
needs:
|
||||||
|
- changes
|
||||||
|
- build-api
|
||||||
|
uses: ./.github/workflows/deploy.yaml
|
||||||
|
with:
|
||||||
|
app_name: flying-api
|
||||||
|
environment_name: test
|
||||||
|
version_number: ${{ github.run_id }}
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
build-app:
|
||||||
|
if: ${{ needs.changes.outputs.app == 'true' }}
|
||||||
|
name: build-app
|
||||||
|
needs:
|
||||||
|
- changes
|
||||||
|
uses: ./.github/workflows/app_build.yaml
|
||||||
|
with:
|
||||||
|
environment_name: test
|
||||||
|
version_number: ${{ github.run_id }}
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
deploy-app:
|
||||||
|
name: deploy-app
|
||||||
|
needs:
|
||||||
|
- changes
|
||||||
|
- build-app
|
||||||
|
uses: ./.github/workflows/deploy.yaml
|
||||||
|
with:
|
||||||
|
app_name: flying-app
|
||||||
|
environment_name: test
|
||||||
|
version_number: ${{ github.run_id }}
|
||||||
|
secrets: inherit
|
||||||
30
.github/workflows/pull_request.yaml
vendored
Normal file
30
.github/workflows/pull_request.yaml
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
name: Pull Request
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
changes:
|
||||||
|
uses: ./.github/workflows/changes.yaml
|
||||||
|
|
||||||
|
build-api:
|
||||||
|
if: ${{ needs.changes.outputs.api == 'true' }}
|
||||||
|
name: build-api
|
||||||
|
needs:
|
||||||
|
- changes
|
||||||
|
uses: ./.github/workflows/api_build.yaml
|
||||||
|
with:
|
||||||
|
environment_name: pull_request
|
||||||
|
version_number: ${{ github.run_id }}
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
build-app:
|
||||||
|
if: ${{ needs.changes.outputs.app == 'true' }}
|
||||||
|
name: build-app
|
||||||
|
needs:
|
||||||
|
- changes
|
||||||
|
uses: ./.github/workflows/app_build.yaml
|
||||||
|
with:
|
||||||
|
environment_name: pull_request
|
||||||
|
version_number: ${{ github.run_id }}
|
||||||
|
secrets: inherit
|
||||||
44
.github/workflows/tag.yaml
vendored
Normal file
44
.github/workflows/tag.yaml
vendored
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
name: Tag
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-api:
|
||||||
|
name: build-api
|
||||||
|
uses: ./.github/workflows/api_build.yaml
|
||||||
|
with:
|
||||||
|
environment_name: prod
|
||||||
|
version_number: ${{ github.ref_name }}
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
deploy-api:
|
||||||
|
name: deploy-api
|
||||||
|
needs:
|
||||||
|
- build-api
|
||||||
|
uses: ./.github/workflows/deploy.yaml
|
||||||
|
with:
|
||||||
|
app_name: flying-api
|
||||||
|
environment_name: prod
|
||||||
|
version_number: ${{ github.ref_name }}
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
build-app:
|
||||||
|
name: build-app
|
||||||
|
uses: ./.github/workflows/app_build.yaml
|
||||||
|
with:
|
||||||
|
environment_name: prod
|
||||||
|
version_number: ${{ github.ref_name }}
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
deploy-app:
|
||||||
|
name: deploy-app
|
||||||
|
needs:
|
||||||
|
- build-app
|
||||||
|
uses: ./.github/workflows/deploy.yaml
|
||||||
|
with:
|
||||||
|
app_name: flying-app
|
||||||
|
environment_name: prod
|
||||||
|
version_number: ${{ github.ref_name }}
|
||||||
|
secrets: inherit
|
||||||
Reference in New Issue
Block a user