-
Notifications
You must be signed in to change notification settings - Fork 51
72 lines (63 loc) · 2.07 KB
/
Copy pathcontainer_image.dev.yaml
File metadata and controls
72 lines (63 loc) · 2.07 KB
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
name: Dev Container Build
on:
push:
branches:
- "**"
workflow_dispatch:
inputs:
image-tag:
description: |
Supply a tag to push the image to ghcr.io with the given tag. Without a tag, the workflow will not push,
but only build the image.
type: string
required: false
permissions:
contents: read
packages: write
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v7
- name: Login to Github Registry ghcr.io
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: image-info
id: image-info
run: |
image_tag="local"
[[ ${{ github.ref }} = 'refs/heads/develop' ]] && image_tag="dev"
[[ -n "${{ inputs.image-tag }}" ]] && image_tag="${{ inputs.image-tag }}"
image_url="${{ github.repository }}/mage:${image_tag}"
echo "using image url ${image_url}"
echo "tag=${image_tag}" >> $GITHUB_OUTPUT
echo "url=ghcr.io/${image_url}" >> $GITHUB_OUTPUT
- name: Build Docker image
run: |
docker build \
-t ${{ steps.image-info.outputs.url }} \
--annotation "org.opencontainers.image.revision=${{ github.sha }}" .
- name: Scan the docker image with Trivy
uses: aquasecurity/trivy-action@v0.35.0
with:
scan-type: 'image'
image-ref: '${{ steps.image-info.outputs.url }}'
ignore-unfixed: true
format: 'table'
output: 'trivy-image-report.txt'
exit-code: '0'
version: 'v0.69.3'
- name: Upload Trivy report
uses: actions/upload-artifact@v7
with:
name: trivy-container-security-report
path: trivy-image-report.txt
retention-days: 7
- name: Push Image
if: ${{ steps.image-info.outputs.tag != 'local' }}
run: |
docker push ${{ steps.image-info.outputs.url }}