Always build to latest #14
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 and Push Docker Image | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Lint Dockerfile with Hadolint | |
uses: hadolint/[email protected] | |
with: | |
dockerfile: Dockerfile | |
- name: Lint Shell Script with ShellCheck | |
uses: ludeeus/action-shellcheck@master | |
- name: Lint Kubernetes resources with KubeLinter | |
id: kube-lint-scan | |
uses: stackrox/kube-linter-action@v1 | |
with: | |
directory: k8s | |
config: .kube-linter/config.yaml | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Build Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
tags: | | |
${{ secrets.DOCKER_USERNAME }}/docker-bitlbee:latest | |
ghcr.io/${{ github.repository_owner }}/docker-bitlbee:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Scan Docker image for vulnerabilities with Trivy | |
uses: aquasecurity/trivy-action@master | |
with: | |
image-ref: ${{ secrets.DOCKER_USERNAME }}/docker-bitlbee:latest | |
format: 'table' | |
ignore-unfixed: true | |
vuln-type: 'os,library' | |
exit-code: '1' | |
severity: 'CRITICAL,HIGH' | |
- name: Upload Trivy Report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: trivy-scan-results | |
path: trivy-results.json | |
- name: Push Docker image | |
run: | | |
docker push ${{ secrets.DOCKER_USERNAME }}/docker-bitlbee:latest | |
docker push ghcr.io/${{ github.repository_owner }}/docker-bitlbee:latest |