-
-
Notifications
You must be signed in to change notification settings - Fork 694
69 lines (58 loc) · 1.95 KB
/
docker.yml
File metadata and controls
69 lines (58 loc) · 1.95 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
# This workflow will build a Java project with Gradle, create repository tag, and push a new docker image to docker hub
name: Create Tag and Push Image to DockerHub
on:
push:
branches: [ master ]
paths-ignore:
- 'metrics/**'
- '**/*.md'
- '*.md'
jobs:
build-and-push:
runs-on: ubuntu-latest
env:
APP_IMAGE: sasanlabs/owasp-vulnerableapp
BASE_IMAGE: sasanlabs/owasp-vulnerableapp-base
steps:
- name: Checkout new changes
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Setup GitVersion action
uses: gittools/actions/gitversion/setup@v0.9.7
with:
versionSpec: '5.x'
- name: Execute GitVersion action
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.7
- name: Create tag for GitHub
uses: tvdias/github-tagger@v0.0.1
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
tag: '${{ steps.gitversion.outputs.semver }}'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build and push base image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.base
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.BASE_IMAGE }}:${{ steps.gitversion.outputs.semver }}
${{ env.BASE_IMAGE }}:latest
- name: Build with Gradle and push app image
run: |
./gradlew jib \
-Djib.to.image=${APP_IMAGE}:unreleased \
-Djib.to.tags=${{ steps.gitversion.outputs.semver }},latest