Skip to content

Commit

Permalink
update node version and create release action
Browse files Browse the repository at this point in the history
  • Loading branch information
jonerrr committed Dec 13, 2024
1 parent b91b246 commit 39ce03e
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 19 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build and push Docker image

on:
release:
types: [published]

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/[email protected]

- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/bus-map:latest
ghcr.io/${{ github.repository_owner }}/bus-map:${{ github.event.release.tag_name }}
67 changes: 50 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,61 @@
name: Build and push Docker image
name: Bump Version and Create Release

on:
release:
types: [published]
workflow_dispatch:
inputs:
type:
required: true
default: 'patch'
description: 'Bump type'
type: choice
options:
- patch
- minor
- major

permissions:
packages: write
contents: write

jobs:
build-and-push:
bump-version:
runs-on: ubuntu-latest

steps:
- name: Checkout
- name: Checkout repository
uses: actions/[email protected]

- name: Login to GitHub Container Registry
uses: docker/[email protected]
- uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/[email protected]
node-version: 23.x
cache: pnpm

- name: Bump version
id: bump_version
run: |
pnpm version ${{ github.event.inputs.type }} -m "ci: bump version to %s"
echo "VERSION=$(node -p "require('./package.json').version")" >> "$GITHUB_ENV"
- name: Push changes
run: |
git push origin main --follow-tags
- name: Create a Release
uses: elgohr/Github-Release-Action@v5
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/bus-map:latest
ghcr.io/${{ github.repository_owner }}/bus-map:${{ github.event.release.tag_name }}
title: Release ${{ env.VERSION }}
tag: ${{ env.VERSION }}
# - name: Create Release
# uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: v${{ env.VERSION }}
# release_name: Release v${{ env.VERSION }}
# body: 'Automated release based on version bump to v${{ env.VERSION }}.'
# draft: false
# prerelease: false
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:22-alpine as build
FROM node:23-alpine as build

RUN npm install -g pnpm

Expand All @@ -14,7 +14,7 @@ FROM node:22-alpine
WORKDIR /app
COPY --from=build /app/build build/
COPY --from=build /app/node_modules node_modules/
COPY --from=build /app/package.json .
COPY --from=build /app/package.json .
EXPOSE 3000
ENV NODE_ENV=production
CMD ["node", "build"]

0 comments on commit 39ce03e

Please sign in to comment.