fix: update Docker build context and Dockerfile path in GitHub Action… #172
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: Docker Image CI | |
on: | |
push: | |
branches: [ "main" ] | |
# paths: | |
# - "src/**" | |
jobs: | |
build: | |
defaults: | |
run: | |
working-directory: ./src | |
env: | |
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_BASE_URL }} | |
NEXTAUTH_CLIENT_ID : ${{ secrets.NEXTAUTH_CLIENT_ID }} | |
NEXT_PUBLIC_APP_URL : ${{ secrets.NEXT_PUBLIC_APP_URL }} | |
NEXT_PUBLIC_SCOPE: ${{ secrets.NEXT_PUBLIC_SCOPE }} | |
NEXT_PUBLIC_UMAMI_SCRIPT_URL: ${{ secrets.NEXT_PUBLIC_UMAMI_SCRIPT_URL }} | |
NEXT_PUBLIC_UMAMI_WEBSITE_ID: ${{ secrets.NEXT_PUBLIC_UMAMI_WEBSITE_ID }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: git config | |
run: | | |
git config user.name "${GITHUB_ACTOR}" | |
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
id: pnpm-install | |
with: | |
version: 8 | |
run_install: false | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build | |
run: pnpm run build | |
- name: Bump version and release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: npx release-it | |
- name: Get version from package.json | |
id: get_version | |
run: | | |
VERSION=$(jq -r '.version' package.json) | |
echo "Version: $VERSION" | |
echo "version=$VERSION" >> $GITHUB_ENV | |
- name: Use version | |
run: echo "The version is ${{ env.version }}" | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker Build and Push | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./src | |
file: ./src/Dockerfile | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository }}:latest | |
ghcr.io/${{ github.repository }}:${{ env.version }} | |
- name: Send Http Post Request to Deploy NextJs App | |
uses: fjogeleit/http-request-action@v1 | |
with: | |
url: ${{ secrets.NEXTJS_WEBHOOK_URL }} | |
method: 'POST' |