-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (63 loc) · 2.22 KB
/
build-and-publish-ansible.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Build and publish docker image for Ansible
on:
push:
branches:
- "*"
schedule:
- cron: "0 2 1 * *"
jobs:
build:
name: Build & push docker image
runs-on: ubuntu-latest
permissions:
packages: write
security-events: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Log in to GitHub packages
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/xima-media/debian-ansible
- name: Build and publish docker image for testing
uses: docker/build-push-action@v5
with:
context: ./debian-ansible
push: true
tags: ghcr.io/xima-media/debian-ansible:test
labels: ${{ steps.meta.outputs.labels }}
- name: Test and get Ansible version
run: |
echo "ANSIBLE_VERSION=$(docker run --rm ghcr.io/xima-media/debian-ansible:test ansible-community --version | cut -d' ' -f4-)" >> $GITHUB_ENV
id: test
- name: Build and publish docker image
uses: docker/build-push-action@v5
with:
context: ./debian-ansible
push: true
tags: ghcr.io/xima-media/debian-ansible:${{ steps.test.outputs.ANSIBLE_VERSION }}
labels: ${{ steps.meta.outputs.labels }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: ghcr.io/xima-media/debian-ansible:${{ steps.test.outputs.ANSIBLE_VERSION }}
format: 'sarif'
output: 'debian-ansible.sarif'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
skip-files: '/root/.ansible/collections/ansible_collections/community/general/plugins/modules/java_keystore.py'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: 'debian-ansible.sarif'