1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-11-06 16:00:28 +01:00
WGDashboard/.github/workflows/main.yml

66 lines
1.9 KiB
YAML
Raw Normal View History

2024-08-24 08:01:56 +02:00
name: Docker Image Build and Analysis
on:
schedule:
- cron: "0 0 * * *" # Schedule the workflow to run daily at midnight (UTC time). Adjust the time if needed.
workflow_dispatch: # Manual run trigger
inputs:
trigger-build:
description: 'Trigger a manual build and push'
default: 'true'
2024-08-24 09:26:30 +02:00
env:
REGISTRY: docker.io
IMAGE_NAME: ${{ github.repository }}
SHA: ${{ github.event.pull_request.head.sha || github.event.after }}
2024-08-24 08:01:56 +02:00
jobs:
build-and-analyze:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
2024-08-24 09:04:46 +02:00
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
2024-08-24 08:22:37 +02:00
- name: Log in to Docker Hub
2024-08-24 08:18:49 +02:00
uses: docker/login-action@v3
2024-08-24 08:01:56 +02:00
with:
2024-08-24 09:26:30 +02:00
registry: ${{ env.REGISTRY }}
2024-08-24 08:22:37 +02:00
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
2024-08-24 09:26:30 +02:00
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4.4.0
with:
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
2024-08-24 08:01:56 +02:00
2024-08-24 09:26:30 +02:00
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4.0.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
2024-08-24 09:28:35 +02:00
- name: Docker Scout
2024-08-24 09:04:46 +02:00
id: docker-scout
2024-08-24 09:28:35 +02:00
if: ${{ github.event_name == 'pull_request' }}
uses: docker/scout-action@dd36f5b0295baffa006aa6623371f226cc03e506
with:
command: cves
image: ${{ steps.meta.outputs.tags }}
exit-code: true