Skip to content

Commit

Permalink
ci: update node and docker
Browse files Browse the repository at this point in the history
  • Loading branch information
stafyniaksacha committed Mar 28, 2024
1 parent 0aa839d commit af40ed3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build-template-action/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ echo "- ${INPUT_PROJECT^} ${INPUT_TAG} template built :rocket:" >> $GITHUB_STEP_

# This step is important, it set the "filepath" output variable
# Will be accessible in workflow
echo "::set-output name=filepath::${ARCHIVE}"
echo "filepath=${ARCHIVE}" >> "$GITHUB_OUTPUT"
22 changes: 10 additions & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,42 @@ concurrency:

jobs:
docker-build:
# We can skip deployment by adding [skip] in the commit body
if: "!contains(github.event.head_commit.message, '[skip]')"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up dockertags
run: |
echo "dockertags=digisquad/cssninja.dokto-demo:latest" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
timeout-minutes: 60
with:
push: true
tags: ${{ env.dockertags }}
cache-from: type=registry,ref=${{ env.dockertags }}
cache-to: type=inline
cache-from: type=gha
cache-to: type=gha,mode=max

deploy:
runs-on: ubuntu-latest
needs: [docker-build]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Prepare
uses: appleboy/ssh-action@master
with:
Expand Down Expand Up @@ -80,5 +78,5 @@ jobs:
script_stop: true
script: |
cd ${{ secrets.HOST_DIRECTORY }}
docker-compose pull
docker-compose up -d --force-recreate --remove-orphans
docker compose pull
docker compose up -d --force-recreate --remove-orphans
29 changes: 12 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,31 @@ on:

jobs:
release:
# setup strategy matrix, so we can share same pnpm cache
strategy:
matrix:
os: [ubuntu-latest]
node-version: [18]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

steps:
# Checkout action retreive the source (git clone)
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed to retreive all git history

# Enable corepack, note that nodejs is already installed
- run: corepack enable

# Setup pnpm with cache
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: 20
cache: "pnpm"

# Compute tag and capitalized product name
- id: meta
name: release meta
run: |
project=${GITHUB_REPOSITORY#*/}
echo ::set-output name=project::${project}
echo ::set-output name=project-capitalized::${project^}
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
echo "PROJECT=${project}" >> "$GITHUB_OUTPUT"
echo "PROJECT_CAP=${project^}" >> "$GITHUB_OUTPUT"
echo "TAG=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
# This is where we generate releases assets.
# It use a github action in the current directory
Expand All @@ -46,8 +41,8 @@ jobs:
name: build release template
uses: ./.github/actions/build-template-action
with:
tag: ${{ steps.meta.outputs.tag }}
project: ${{ steps.meta.outputs.project }}
tag: ${{ steps.meta.outputs.TAG }}
project: ${{ steps.meta.outputs.PROJECT }}

# We re-generate the changelog using a subset of standard-version
# The content is generated in a temp /CHANGELOG_RELEASE.md file
Expand All @@ -61,11 +56,11 @@ jobs:
# Prepare the draft github release
- id: create_release
name: create github draft release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
# Use outputs from meta and changelog
tag_name: ${{ steps.meta.outputs.tag }}
name: ${{ steps.meta.outputs.project-capitalized }} ${{ steps.meta.outputs.tag }}
tag_name: ${{ steps.meta.outputs.TAG }}
name: ${{ steps.meta.outputs.PROJECT_CAP }} ${{ steps.meta.outputs.TAG }}
body_path: ${{ github.workspace }}/CHANGELOG_RELEASE.md
prerelease: false
# The draft is required to allow file upload
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/standard-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,11 @@ on:

jobs:
standard-version:
# setup strategy matrix, so we can share same pnpm cache
strategy:
matrix:
os: [ubuntu-latest]
node-version: [18]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

steps:
# Checkout action retreive the source (git clone)
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed to retreive all git history
token: ${{ secrets.APP_GITHUB_TOKEN }}
Expand All @@ -29,9 +24,9 @@ jobs:
- run: corepack enable

# Setup pnpm with cache
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: 20
cache: "pnpm"

# Run "standard-version", which may create a new tag
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM bitnami/node:18 AS build
FROM bitnami/node:20 AS build
WORKDIR /app

RUN corepack enable
Expand All @@ -12,7 +12,7 @@ COPY . .
RUN pnpm build


FROM bitnami/nginx:1.22 AS prod
FROM bitnami/nginx:1.25 AS prod
WORKDIR /app

COPY --from=build /app/dist .
Expand Down
7 changes: 3 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
version: '3.7'
networks:
cssninja-services:
external: true

services:
dokto-demo:
Expand All @@ -18,6 +20,3 @@ services:
traefik.http.routers.dokto-demo-https.entrypoints: 'https'
traefik.http.routers.dokto-demo-https.tls.certresolver: 'http'

networks:
cssninja-services:
external: true

0 comments on commit af40ed3

Please sign in to comment.