Skip to content

Commit

Permalink
feat: deployment stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Sv443 committed Jan 12, 2024
1 parent 8347b04 commit 5e8e2e4
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 47 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build-deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "Build and Deploy to Prod"

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
publish:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Determine latest version
run: echo "APP_VERSION=$(git describe --tags || git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build docker image and push
uses: docker/build-push-action@v4
with:
context: ./
file: ./Dockerfile
build-args: APP_VERSION=${{ env.APP_VERSION }}
push: true
tags: ghcr.io/sv443-network/jokeapi:latest

- name: Delete old packages
uses: actions/delete-package-versions@v4
with:
package-name: ${{ github.event.repository.name }}
package-type: "container"
min-versions-to-keep: 3
delete-only-untagged-versions: "true"

- name: Deploy to prod
run: echo "TODO Trigger prod deployment here"
50 changes: 50 additions & 0 deletions .github/workflows/build-deploy-stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "Build and Deploy to Stage"

on:
push:
branches:
- v3

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
publish:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Determine latest version
run: echo "APP_VERSION=$(git describe --tags || git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build docker image and push
uses: docker/build-push-action@v4
with:
context: ./
file: ./Dockerfile
build-args: APP_VERSION=${{ env.APP_VERSION }}
push: true
tags: ghcr.io/sv443-network/jokeapi-stage:latest

- name: Delete old packages
uses: actions/delete-package-versions@v4
with:
package-name: ${{ github.event.repository.name }}
package-type: "container"
min-versions-to-keep: 3
delete-only-untagged-versions: "true"

- name: Deploy to stage
run: echo "TODO Trigger stage deployment here"
45 changes: 0 additions & 45 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

45 changes: 45 additions & 0 deletions .github/workflows/lint-and-analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Lint and Analyze Code"

on:
push:
branches: [main, v3]
pull_request:
branches: [main, v3]

jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint

analyze:
name: Analyze Code
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
matrix:
language: ["javascript"]

steps:
- uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM node:alpine
FROM node:20-alpine

# Set working directory
WORKDIR /app

# Install app dependencies
COPY package.json ./
RUN npm install
RUN npm i

# Copy app source code
COPY . .
Expand Down

0 comments on commit 5e8e2e4

Please sign in to comment.