From 7c2dd73b514e13a8c226927c5cb44e0f6c8c3b1f Mon Sep 17 00:00:00 2001 From: Wonderfall Date: Wed, 2 Jun 2021 19:11:41 +0200 Subject: [PATCH] add build workflow --- .github/workflows/build.yml | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..8f4c4fc --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,51 @@ +name: build + +on: + workflow_dispatch: + push: + branches: [ main ] + schedule: + # Build the image regularly (each Friday) + - cron: '13 21 * * 5' + +jobs: + build: + name: Build, scan & push + runs-on: "ubuntu-20.04" + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build an image from Dockerfile + run: | + docker build \ + -t ghcr.io/wonderfall/synapse \ + -t ghcr.io/wonderfall/synapse:$(grep -oP '(?<=SYNAPSE_VERSION=).*' Dockerfile | head -c6) \ + -t ghcr.io/wonderfall/synapse:$(grep -oP '(?<=SYNAPSE_VERSION=).*' Dockerfile | head -c4) \ + . + + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@master + with: + image-ref: 'ghcr.io/wonderfall/synapse' + format: 'template' + template: '@/contrib/sarif.tpl' + output: 'trivy-results.sarif' + severity: 'CRITICAL,HIGH' + vuln-type: "os" + + - name: Upload Trivy scan results to GitHub Security tab + uses: github/codeql-action/upload-sarif@v1 + with: + sarif_file: 'trivy-results.sarif' + + - name: Docker login + run: >- + echo "${{ secrets.GHCR_TOKEN }}" + | docker login -u "${{ github.actor }}" --password-stdin ghcr.io + + - name: Push image to GitHub + run: | + docker push ghcr.io/wonderfall/synapse + docker push ghcr.io/wonderfall/synapse:$(grep -oP '(?<=SYNAPSE_VERSION=).*' Dockerfile | head -c6) + docker push ghcr.io/wonderfall/synapse:$(grep -oP '(?<=SYNAPSE_VERSION=).*' Dockerfile | head -c4) \ No newline at end of file