63 lines
1.5 KiB
YAML
63 lines
1.5 KiB
YAML
name: 'API Build and Deploy'
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
calling_workflow:
|
|
required: true
|
|
type: string
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
environment: ${{ inputs.calling_workflow }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: true
|
|
|
|
- name: 'Setup Node'
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ vars.NODE_VERSION }}
|
|
|
|
- name: Install
|
|
run: |
|
|
npm install
|
|
|
|
- name: Build
|
|
shell: bash
|
|
run: |
|
|
npm run build -w api
|
|
|
|
- name: Setup Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log into Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ vars.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Build and push to registry
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
push: true
|
|
tags: noahspan/flying-api:${{ github.run_id }}
|
|
file: ./api/Dockerfile
|
|
context: ./api
|
|
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
environment: ${{ inputs.calling_workflow }}
|
|
needs: build
|
|
steps:
|
|
- name: Log in to Azure
|
|
uses: azure/login@v2
|
|
with:
|
|
creds: ${{ secrets.AZURE_CREDENTIALS }}
|
|
|
|
- name: Update Container App
|
|
run: |
|
|
az container app update --name flying-api --resource-group noahspan --image noahspan-flying:${{ github.run_id }}
|