mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-06 16:00:28 +01:00
Update main.yml
This commit is contained in:
parent
4c80dc256b
commit
9fe2aa9ed5
53
.github/workflows/main.yml
vendored
53
.github/workflows/main.yml
vendored
@ -1,3 +1,5 @@
|
|||||||
|
name: Docker Image Build and Analysis
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 0 * * *" # Schedule the workflow to run daily at midnight (UTC time). Adjust the time if needed.
|
- cron: "0 0 * * *" # Schedule the workflow to run daily at midnight (UTC time). Adjust the time if needed.
|
||||||
@ -7,11 +9,6 @@ on:
|
|||||||
description: 'Trigger a manual build and push'
|
description: 'Trigger a manual build and push'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: docker.io
|
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
|
||||||
SHA: ${{ github.event.pull_request.head.sha || github.event.after }}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-analyze:
|
build-and-analyze:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -20,45 +17,23 @@ jobs:
|
|||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Extract Docker metadata
|
- name: Build Docker image
|
||||||
id: meta
|
id: build-image
|
||||||
uses: docker/metadata-action@v4.4.0
|
run: |
|
||||||
with:
|
docker build -t my-app-image:latest .
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
||||||
labels: |
|
|
||||||
org.opencontainers.image.revision=${{ env.SHA }}
|
|
||||||
tags: |
|
|
||||||
type=edge,branch=$repo.default_branch
|
|
||||||
type=semver,pattern=v{{version}}
|
|
||||||
type=sha,prefix=,suffix=,format=short
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Install Docker Scout
|
||||||
id: build-and-push
|
run: |
|
||||||
uses: docker/build-push-action@v4.0.0
|
curl -sSfL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh | sh -s --
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
- name: Docker Scout
|
- name: Analyze Docker image with Docker Scout
|
||||||
id: docker-scout
|
id: analyze-image
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
run: |
|
||||||
uses: docker/scout-action@dd36f5b0295baffa006aa6623371f226cc03e506
|
docker scout cves my-app-image:latest > scout-results.json
|
||||||
with:
|
cat scout-results.json # Print the report to the workflow logs for easy viewing
|
||||||
command: cves
|
|
||||||
only-severities: critical,high,medium,low,unspecified
|
|
||||||
image: ${{ steps.meta.outputs.tags }}
|
|
||||||
exit-code: true
|
|
||||||
|
Loading…
Reference in New Issue
Block a user