-
Notifications
You must be signed in to change notification settings - Fork 2
54 lines (51 loc) · 1.77 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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