Update dependencies #13
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 Scan Docker Image | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- 'Dockerfile' | |
- '.dockerignore' | |
- 'package.json' | |
- 'package-lock.json' | |
- 'tsconfig.json' | |
- '.github/workflows/build.yaml' | |
jobs: | |
build-docker-image: | |
runs-on: ubuntu-24.04 | |
outputs: | |
image_tag: ${{ steps.vars.outputs.commit_hash }} | |
tar_file: ${{ steps.vars.outputs.tar_file }} | |
image_name: ${{ steps.vars.outputs.image_name }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Get Commit Hash | |
id: vars | |
run: | | |
commit_hash=$(git rev-parse --short HEAD) | |
tar_file="ndc-openapi-${commit_hash}.tar" | |
image_name="ndc-openapi:${commit_hash}" | |
echo "commit_hash: $commit_hash" | |
echo "tar_file: $tar_file" | |
echo "image_name: $image_name" | |
echo "commit_hash=$commit_hash" >> $GITHUB_ENV | |
echo "tar_file=$tar_file" >> $GITHUB_ENV | |
echo "image_name=$image_name" >> $GITHUB_ENV | |
echo "::set-output name=commit_hash::$commit_hash" | |
echo "::set-output name=tar_file::$tar_file" | |
echo "::set-output name=image_name::$image_name" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build Docker image | |
run: | | |
docker build -t $image_name . | |
- name: Save Docker image as artifact | |
run: | | |
docker save -o $tar_file $image_name | |
- name: Upload Docker image artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.tar_file }} | |
path: ${{ env.tar_file }} | |
retention-days: 1 | |
scan-docker-image-with-gokakashi: | |
needs: build-docker-image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Docker image artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ needs.build-docker-image.outputs.tar_file }} | |
- name: Load Docker image | |
run: | | |
docker load -i ${{ needs.build-docker-image.outputs.tar_file }} | |
- name: Scan docker image with gokakashi | |
uses: shinobistack/[email protected] | |
with: | |
image-ref: '${{ needs.build-docker-image.outputs.image_name }}' | |
labels: agentKey=${{ github.run_id }} | |
policy: ci-platform | |
server: https://gokakashi-server.hasura-app.io | |
token: ${{ secrets.GOKAKASHI_API_TOKEN }} | |
cf_client_id: ${{ secrets.CF_ACCESS_CLIENT_ID }} | |
cf_client_secret: ${{ secrets.CF_ACCESS_CLIENT_SECRET }} | |
interval: 10 | |
retries: 8 |