Merge pull request #1484 from PhilanthropyDataCommons/add-patch-chang… #840
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: Build and push docker image | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: philanthropydatacommons/service | |
on: | |
push: | |
branches: | |
- 'main' | |
jobs: | |
build-and-push-docker-image: | |
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-file: .node-version | |
- 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: Wait for lint, test, and other workflows to succeed | |
uses: kachick/wait-other-jobs@v3 | |
timeout-minutes: 24 | |
with: | |
wait-list: | | |
[ | |
{ | |
"workflowFile": "lint.yml" | |
}, | |
{ | |
"workflowFile": "test.yml" | |
}, | |
{ | |
"workflowFile": "sdk.yml" | |
} | |
] | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
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 |