Add lint, build, deploy jobs to github action #2
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: Continuous Integration and Continuous Delivery | |
on: | |
push: | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout to the branch | |
uses: actions/checkout@v4 | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | |
name: List the state of node modules | |
continue-on-error: true | |
run: npm list | |
- name: Install dependencies | |
run: npm install | |
# - name: Typecheck | |
# run: npm run typecheck | |
- name: Lint ESLint | |
run: npm run lint | |
- name: Lint Prettier | |
run: npm run prettier | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout to the branch | |
uses: actions/checkout@v4 | |
- name: Docker Login | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ secrets.ACR_URL }} | |
username: ${{ secrets.ACR_USERNAME }} | |
password: ${{ secrets.ACR_PASSWORD }} | |
- name: Build and Push to ACR | |
uses: docker/build-push-action@v2 | |
with: | |
push: ${{ github.ref == 'refs/heads/main' }} | |
tags: ${{ secrets.ACR_URL }}/krokelo:${{ github.sha }} | |
file: Dockerfile | |
build-args: | | |
DATABASE_URL=${{ secrets.DATABASE_URL }} | |
deploy: | |
if: ${{ github.ref == 'refs/heads/main' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Azure Login | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: Redeploy Azure Container App | |
run: | | |
az containerapp revision copy \ | |
--name krokelo \ | |
--resource-group sbu-public-krokelo-nww-nea-rg \ | |
--cpu 1 \ | |
--memory 2.0 \ | |
--image ${{ secrets.ACR_URL }}/krokelo:${{ github.sha }} |