-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (59 loc) · 2.16 KB
/
build-publish-jenkins-image.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
name: build-publish-jenkins-image
on:
# push:
# branches:
# - main
workflow_dispatch:
schedule:
- cron: '0 0 5,20 * *'
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Git config and create new tag
run: |
# Run bash script to get new tag
bash get_latest_version_create_tag.sh
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and publish docker image with tag
# env:
# NEW_VERSION: $NEW_VERSION
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ secrets.DOCKERHUB_USERNAME }}/jenkins-core-image:${{ env.NEW_VERSION }}
build-args: |
"JENKINS_USER=${{ secrets.JENKINS_USER }}"
"JENKINS_PASS=${{ secrets.JENKINS_PASS }}"
"GITHUB_APP_KEY=${{ secrets.GH_APP_KEY }}"
"GITHUB_APP_ID=${{ secrets.GH_APP_ID }}"
- name: Build and Publish docker image with latest tag
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ secrets.DOCKERHUB_USERNAME }}/jenkins-core-image:latest
build-args: |
"JENKINS_USER=${{ secrets.JENKINS_USER }}"
"JENKINS_PASS=${{ secrets.JENKINS_PASS }}"
"GITHUB_APP_KEY=${{ secrets.GH_APP_KEY }}"
"GITHUB_APP_ID=${{ secrets.GH_APP_ID }}"
- name: set up docker and scan docker image for vulnerabilities
uses: docker-practice/actions-setup-docker@master
- run: |
set -x
docker version
docker run -v /var/run/docker.sock:/var/run/docker.sock aquasec/trivy image ${{ secrets.DOCKERHUB_USERNAME }}/jenkins-core-image:latest