Merge pull request #81 from jd-apprentice/development #10
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: CI/CD | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
- development | |
paths: | |
- "src/**" | |
- "Dockerfile" | |
- ".github/workflows/*.yml" | |
pull_request: | |
branches: | |
- master | |
- development | |
paths: | |
- "src/**" | |
- "Dockerfile" | |
env: | |
BRANCH_NAME: ${{ github.ref_name }} | |
APP_NAME: waifuland_api | |
APP_VERSION: latest | |
APP_DEV_VERSION: unstable | |
jobs: | |
gitleaks: | |
uses: jd-apprentice/jd-workflows/.github/workflows/gitleaks.yml@main | |
with: | |
runs-on: ubuntu-latest | |
name: Gitleaks | |
secrets: | |
gh_token: ${{ secrets.GITHUB_TOKEN }} | |
test: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
## TODO: Add envs for cloudinary | |
- name: install dependencies and test | |
run: | | |
touch .env | |
echo DB_HOST="${{ secrets.DB_HOST }}" >> .env | |
echo PORT=3000 >> .env | |
echo NODE_ENV=TEST >> .env | |
echo ROLLBAR_TOKEN="${{ secrets.ROLLBAR_TOKEN }}" >> .env | |
echo ROLLBAR_ENVIRONMENT=development >> .env | |
echo TOKEN="${{ secrets.TOKEN }}" >> .env | |
bun install | |
bun test | |
codacy: | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: jd-apprentice/jd-workflows/.github/workflows/codacy.yml@main | |
needs: [gitleaks, test] | |
with: | |
name: Codacy | |
secrets: | |
project_token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
dev: | |
runs-on: ubuntu-latest | |
needs: [gitleaks, test] | |
if: ${{ github.ref_name == 'development' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and push - AMD64 - UNSTABLE | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: docker/Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}:X64_${{ env.APP_DEV_VERSION }} | |
platforms: linux/amd64 | |
- name: Build and push - ARM64 - UNSTABLE | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: docker/ARM64.Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}:ARM64_${{ env.APP_DEV_VERSION }} | |
platforms: linux/arm64 | |
prod: | |
runs-on: ubuntu-latest | |
needs: [gitleaks, test] | |
if: ${{ github.ref_name == 'master' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and push - AMD64 - PROD | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: docker/Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}:X64_${{ env.APP_VERSION }} | |
platforms: linux/amd64 | |
- name: Build and push - ARM64 - PROD | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: docker/ARM64.Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.APP_NAME }}:ARM64_${{ env.APP_VERSION }} | |
platforms: linux/arm64 |