-
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.
Merge pull request #2 from sparebank1utvikling/dev
Add lint, build, deploy jobs to github action
- Loading branch information
Showing
3 changed files
with
94 additions
and
44 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,90 @@ | ||
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 --prefer-offline | ||
|
||
# - 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 | ||
needs: [lint, build] | ||
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 }} |
This file was deleted.
Oops, something went wrong.
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