2022-04-02 20:27:13 +00:00
|
|
|
name: CI/CD
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- "[0-9]+.[0-9]+.[0-9]+"
|
|
|
|
schedule:
|
|
|
|
- cron: "0 5 * * 0"
|
2022-07-13 01:51:45 +00:00
|
|
|
workflow_dispatch:
|
2022-04-02 20:27:13 +00:00
|
|
|
|
|
|
|
env:
|
|
|
|
USER: loganmarchione
|
|
|
|
REPO: docker-webdav-nginx
|
|
|
|
|
|
|
|
jobs:
|
2022-12-28 21:59:08 +00:00
|
|
|
ci:
|
2022-04-02 20:27:13 +00:00
|
|
|
name: Build and test
|
|
|
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Check out the codebase
|
2022-05-24 18:05:03 +00:00
|
|
|
uses: actions/checkout@v3
|
2022-04-02 20:27:13 +00:00
|
|
|
|
|
|
|
- name: Set variables
|
|
|
|
run: |
|
|
|
|
VER=$(cat VERSION)
|
|
|
|
echo "VERSION=$VER" >> $GITHUB_ENV
|
|
|
|
|
2022-04-06 17:14:06 +00:00
|
|
|
- name: Set up Docker Buildx
|
2022-10-17 15:57:28 +00:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2022-04-06 17:14:06 +00:00
|
|
|
|
2022-04-02 20:27:13 +00:00
|
|
|
- name: Build Docker Image
|
2023-01-30 19:47:12 +00:00
|
|
|
uses: docker/build-push-action@v4
|
2022-04-02 20:27:13 +00:00
|
|
|
with:
|
|
|
|
push: false
|
|
|
|
context: .
|
|
|
|
file: Dockerfile
|
|
|
|
load: true
|
|
|
|
tags: |
|
|
|
|
${{ env.USER }}/${{ env.REPO }}:${{ env.VERSION }}
|
|
|
|
${{ env.USER }}/${{ env.REPO }}:latest
|
|
|
|
|
|
|
|
- name: Test image
|
|
|
|
run: |
|
|
|
|
docker images
|
2022-04-02 20:46:17 +00:00
|
|
|
docker run --name test-container --detach --env WEBDAV_USER=user --env WEBDAV_PASS=password1 --volume 'webdav:/var/www/webdav' ${USER}/${REPO}:${VERSION}
|
2022-04-02 20:27:13 +00:00
|
|
|
docker ps -a
|
|
|
|
|
2022-12-28 21:59:08 +00:00
|
|
|
- name: Container scan with Dockle
|
2023-01-03 15:32:34 +00:00
|
|
|
uses: goodwithtech/dockle-action@0.1.0
|
2022-04-02 20:27:13 +00:00
|
|
|
with:
|
2023-01-03 15:32:34 +00:00
|
|
|
image: '${{ env.USER }}/${{ env.REPO }}:${{ env.VERSION }}'
|
|
|
|
format: 'list'
|
|
|
|
exit-code: '1'
|
|
|
|
exit-level: 'warn'
|
|
|
|
ignore: 'CIS-DI-0001'
|
2022-04-02 20:27:13 +00:00
|
|
|
|
2023-03-27 20:40:41 +00:00
|
|
|
- name: Container scan with hadolint
|
|
|
|
uses: hadolint/hadolint-action@v3.1.0
|
|
|
|
with:
|
|
|
|
failure-threshold: error
|
|
|
|
ignore: DL3008,DL3018
|
|
|
|
|
2022-12-28 21:59:08 +00:00
|
|
|
- name: Container scan with Trivy
|
2023-03-07 16:10:26 +00:00
|
|
|
uses: aquasecurity/trivy-action@0.9.2
|
2022-12-28 21:59:08 +00:00
|
|
|
with:
|
|
|
|
scan-type: 'image'
|
|
|
|
image-ref: '${{ env.USER }}/${{ env.REPO }}:${{ env.VERSION }}'
|
|
|
|
trivy-config: ./github/trivy.yaml
|
|
|
|
|
|
|
|
cd:
|
2022-04-02 20:27:13 +00:00
|
|
|
name: Deploy
|
|
|
|
|
2022-12-28 21:59:08 +00:00
|
|
|
needs: ci
|
2022-04-02 20:27:13 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Check out the codebase
|
2022-05-24 18:05:03 +00:00
|
|
|
uses: actions/checkout@v3
|
2022-04-02 20:27:13 +00:00
|
|
|
|
|
|
|
- name: Set variables
|
|
|
|
run: |
|
|
|
|
VER=$(cat VERSION)
|
|
|
|
echo "VERSION=$VER" >> $GITHUB_ENV
|
|
|
|
|
2022-04-17 01:36:03 +00:00
|
|
|
- name: Set up QEMU
|
2022-10-17 15:57:34 +00:00
|
|
|
uses: docker/setup-qemu-action@v2
|
2022-04-17 01:36:03 +00:00
|
|
|
|
2022-04-02 20:27:13 +00:00
|
|
|
- name: Set up Docker Buildx
|
2022-10-17 15:57:28 +00:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2022-04-02 20:27:13 +00:00
|
|
|
|
|
|
|
- name: Login to DockerHub
|
2022-10-17 15:57:24 +00:00
|
|
|
uses: docker/login-action@v2
|
2022-04-02 20:27:13 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_HUB_USER }}
|
|
|
|
password: ${{ secrets.DOCKER_HUB_PASS }}
|
|
|
|
logout: true
|
|
|
|
|
|
|
|
- name: Build Docker Image
|
2023-01-30 19:47:12 +00:00
|
|
|
uses: docker/build-push-action@v4
|
2022-04-02 20:27:13 +00:00
|
|
|
with:
|
|
|
|
push: true
|
|
|
|
context: .
|
|
|
|
file: Dockerfile
|
2022-04-17 01:36:03 +00:00
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
2022-04-02 20:27:13 +00:00
|
|
|
tags: |
|
|
|
|
${{ env.USER }}/${{ env.REPO }}:${{ env.VERSION }}
|
2022-04-02 20:46:17 +00:00
|
|
|
${{ env.USER }}/${{ env.REPO }}:latest
|