-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from 42Crunch/github-actions
GitHub actions
- Loading branch information
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: docker-build | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
env: | ||
REGISTRY: docker.io | ||
IMAGE_NAME: 42crunch/scand-manager | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
name: Login to Registry ${{ env.REGISTRY }} | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- | ||
name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
- | ||
name: Build and export to Docker | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
load: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
- | ||
name: Scan image | ||
id: scan | ||
uses: Azure/container-scan@v0 | ||
with: | ||
image-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
severity-threshold: CRITICAL | ||
run-quality-checks: true | ||
- | ||
name: Build and push | ||
if: success() | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: docker-scan | ||
|
||
on: | ||
schedule: | ||
- cron: '30 2 * * *' | ||
|
||
env: | ||
REGISTRY: docker.io | ||
IMAGE_NAME: 42crunch/scand-manager | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Scan image | ||
id: scan | ||
uses: Azure/container-scan@v0 | ||
with: | ||
image-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
severity-threshold: CRITICAL | ||
run-quality-checks: true | ||
- | ||
name: Send mail | ||
if: failure() | ||
run: | | ||
cat <<EOF > email.txt | ||
From: No Reply <[email protected]> | ||
To: Security <[email protected]> | ||
Subject: Container Scan Report of ${{ github.repository }} | ||
Date: $(date) | ||
$(cat ${{ steps.scan.outputs.scan-report-path }}) | ||
$(cat ${{ steps.scan.outputs.check-run-url }}) | ||
EOF | ||
curl \ | ||
--ssl-reqd smtp://smtp.gmail.com \ | ||
--mail-from [email protected] \ | ||
--mail-rcpt [email protected] \ | ||
--upload-file email.txt \ | ||
--user ${{ secrets.MAIL_USERNAME }}:${{ secrets.MAIL_PASSWORD }} |