autofill #369
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
# create github action that will build nextjs application and push it to docker hub and tag with commit hash | |
# apply this to every push to dev and pull request | |
name: Build on every push to main | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "src/**" | |
- "prisma/**" | |
- "public/**" | |
workflow_dispatch: | |
jobs: | |
web_lint_test: | |
name: Web - Lint - Format - Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
- uses: actions/setup-node@master | |
with: | |
node-version: 18.x | |
# write local env file .env with secrets | |
# add dummy keys to get the required markers for next-auth and postgres | |
- name: Write local dummy env file ( lint ) | |
run: | | |
echo "DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres?schema=public" >> .env | |
echo "NEXTAUTH_SECRET=dummy_key" >> .env | |
echo "NEXTAUTH_URL=http://localhost:3000" >> .env | |
echo "NEXT_PUBLIC_SITE_NAME=ZTnet" >> .env | |
echo "NEXT_PUBLIC_APP_VERSION=" >> .env | |
echo "IS_GITHUB_ACTION=true" >> .env | |
- run: npm install | |
- name: Lint | |
run: npm run lint | |
- name: Formatter | |
run: npm run format | |
- name: Test | |
run: npm run test | |
build: | |
runs-on: ubuntu-latest | |
needs: web_lint_test | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- id: lowercaseRepo | |
uses: ASzc/change-string-case-action@v5 | |
with: | |
string: ${{ github.repository }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Create short sha | |
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
build-args: | | |
"NEXT_PUBLIC_APP_VERSION=${{ github.ref_name }}-${{ env.SHORT_SHA }}" | |
# platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
tags: | | |
${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:dev-${{ env.SHORT_SHA }} | |
${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:latest-dev |