1.0.50 Add variables to the github action #23
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
name: build-scan-push-to-dockerhub | |
on: | |
push: | |
branches: | |
- 'main' | |
env: | |
DATABASE_CONTAINER_NAME: "database" | |
DATABASE_ADMIN_CONTAINER_NAME: "database_admin" | |
LDAP_CONTAINER_NAME: "ldap" | |
LDAP_ADMIN_CONTAINER_NAME: "ldap_admin" | |
WEB_CONTAINER_NAME: "www" | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
# -------------------------------------- | |
# Prepare the runner | |
# -------------------------------------- | |
- | |
name: Check out the codebase | |
uses: actions/checkout@v4 | |
- | |
name: Get version from version file | |
run: | | |
VERSION=$(cat version) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- | |
name: Set up QEMU on the runner | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Docker Buildx on the runner | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# ---------------------------------------------------------------------------- | |
# Database Container | |
# ---------------------------------------------------------------------------- | |
- | |
name: Build and Export Database Container to Docker | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./${{ env.DATABASE_CONTAINER_NAME }}/Dockerfile | |
load: true | |
tags: webpwnized/mutillidae:${{ env.DATABASE_CONTAINER_NAME }} | |
- | |
name: Run Trivy vulnerability scanner on Database Container | |
uses: aquasecurity/trivy-action@master | |
with: | |
image-ref: 'webpwnized/mutillidae:${{ env.DATABASE_CONTAINER_NAME }}' | |
format: 'sarif' | |
output: '${{ env.DATABASE_CONTAINER_NAME }}-trivy-scan-results.sarif' | |
- | |
name: Upload Database Container Trivy scan results to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@v2 | |
with: | |
sarif_file: '${{ env.DATABASE_CONTAINER_NAME }}-trivy-scan-results.sarif' | |
- | |
name: Build and push Database container | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./${{ env.DATABASE_CONTAINER_NAME }}/Dockerfile | |
push: true | |
tags: webpwnized/mutillidae:${{ env.DATABASE_CONTAINER_NAME }} | |
- | |
name: Build and push Database container with version number | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./${{ env.DATABASE_CONTAINER_NAME }}/Dockerfile | |
push: true | |
tags: webpwnized/mutillidae:${{ env.DATABASE_CONTAINER_NAME }}-${{ env.VERSION }} | |
- | |
name: Build and push database_admin container | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./database_admin/Dockerfile | |
push: true | |
tags: webpwnized/mutillidae:database_admin | |
- | |
name: Build and push database_admin container | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./database_admin/Dockerfile | |
push: true | |
tags: webpwnized/mutillidae:database_admin-${{ env.VERSION }} | |
- | |
name: Build and push ldap container | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./ldap/Dockerfile | |
push: true | |
tags: webpwnized/mutillidae:ldap | |
- | |
name: Build and push ldap container | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./ldap/Dockerfile | |
push: true | |
tags: webpwnized/mutillidae:ldap-${{ env.VERSION }} | |
- | |
name: Build and push ldap_admin container | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./ldap_admin/Dockerfile | |
push: true | |
tags: webpwnized/mutillidae:ldap_admin | |
- | |
name: Build and push ldap_admin container | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./ldap_admin/Dockerfile | |
push: true | |
tags: webpwnized/mutillidae:ldap_admin-${{ env.VERSION }} | |
- | |
name: Build and push www container | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./www/Dockerfile | |
push: true | |
tags: webpwnized/mutillidae:www | |
- | |
name: Build and push www container | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./www/Dockerfile | |
push: true | |
tags: webpwnized/mutillidae:www-${{ env.VERSION }} | |