mirror of
https://github.com/tommytran732/Synapse-Docker
synced 2024-11-25 21:51:34 -05:00
refactor workflow
This commit is contained in:
parent
5b6e336523
commit
6f1c1932c0
83
.github/workflows/build.yml
vendored
83
.github/workflows/build.yml
vendored
@ -3,49 +3,76 @@ name: build
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches:
|
||||||
|
- main
|
||||||
|
# Ignore Markdown files
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
schedule:
|
schedule:
|
||||||
# Build the image regularly (each Friday)
|
# Build the image regularly (each Friday)
|
||||||
- cron: '13 21 * * 5'
|
- cron: '13 21 * * 5'
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: wonderfall/synapse
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build, scan & push
|
name: Build, scan & push
|
||||||
runs-on: "ubuntu-20.04"
|
runs-on: "ubuntu-latest"
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Build an image from Dockerfile
|
- name: Extract version for tags
|
||||||
run: |
|
run: |
|
||||||
docker build \
|
echo "FULL_VERSION=$(grep -oP '(?<=SYNAPSE_VERSION=).*' Dockerfile | head -c6)" >> $GITHUB_ENV
|
||||||
-t ghcr.io/wonderfall/synapse \
|
echo "MAJOR_VERSION=$(grep -oP '(?<=SYNAPSE_VERSION=).*' Dockerfile | head -c4)" >> $GITHUB_ENV
|
||||||
-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
|
- name: Install cosign
|
||||||
uses: aquasecurity/trivy-action@master
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: sigstore/cosign-installer@main
|
||||||
with:
|
with:
|
||||||
image-ref: 'ghcr.io/wonderfall/synapse'
|
cosign-release: 'v1.11.0'
|
||||||
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
|
- name: Set up Docker Buildx
|
||||||
uses: github/codeql-action/upload-sarif@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login to registry
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
sarif_file: 'trivy-results.sarif'
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Docker login
|
- name: Set Docker metadata
|
||||||
run: >-
|
id: meta
|
||||||
echo "${{ secrets.GITHUB_TOKEN }}"
|
uses: docker/metadata-action@v4
|
||||||
| docker login -u "${{ github.actor }}" --password-stdin ghcr.io
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
latest
|
||||||
|
${{ env.FULL_VERSION }}
|
||||||
|
${{ env.MAJOR_VERSION }}
|
||||||
|
|
||||||
- name: Push image to GitHub
|
- name: Build and push Docker image
|
||||||
run: |
|
id: build-and-push
|
||||||
docker push ghcr.io/wonderfall/synapse
|
uses: docker/build-push-action@v3
|
||||||
docker push ghcr.io/wonderfall/synapse:$(grep -oP '(?<=SYNAPSE_VERSION=).*' Dockerfile | head -c6)
|
with:
|
||||||
docker push ghcr.io/wonderfall/synapse:$(grep -oP '(?<=SYNAPSE_VERSION=).*' Dockerfile | head -c4)
|
context: .
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
|
- name: Sign the published Docker image
|
||||||
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
run: cosign sign ${TAGS}
|
||||||
|
env:
|
||||||
|
COSIGN_EXPERIMENTAL: "true"
|
||||||
|
TAGS: ${{ steps.meta.outputs.tags }}
|
||||||
|
Loading…
Reference in New Issue
Block a user