Skip to content

Merge pull request #655 from PhilanthropyDataCommons/dependabot/npm_a… #398

Merge pull request #655 from PhilanthropyDataCommons/dependabot/npm_a…

Merge pull request #655 from PhilanthropyDataCommons/dependabot/npm_a… #398

Workflow file for this run

name: Build
env:
REGISTRY: ghcr.io
IMAGE_NAME: philanthropydatacommons/service
on:
push:
branches:
- 'main'
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out code
uses: actions/checkout@v4
- run: echo VERSION=$(git log -1 --date=unix --pretty=format:"%cd" | date --utc +%Y%m%d)-$(git log -1 --pretty=format:"%h") >> $GITHUB_ENV
- name: Build with node
uses: actions/setup-node@v4
with:
node-version: 18.17.1
- run: npm ci
- run: npm run build
- run: npm prune --omit=dev
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
- name: Notify the top-level 'deploy' project that an image was pushed
uses: pauldraper/[email protected]
with:
workflow: update-service-image.yml
ref: main
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repo: PhilanthropyDataCommons/deploy
inputs: "{\"image-tag\":\"${{ env.VERSION }}\"}"
wait: true