-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (45 loc) · 1.61 KB
/
build-examples.yml
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
name: Build Examples
# Controls when the workflow will run
on:
push:
paths:
- 'examples/**'
pull_request:
paths:
- 'examples/**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
deploy-example:
type: choice
description: Example to Deploy
options:
- None
- WordCount
jobs:
build-examples:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Runs a set of commands using the runners shell
- name: Maven Package
run: |
cd examples/[email protected]/word-count
mvn clean package
version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
timestamp=$(date +"%Y%m%d%H%M%S")
version_with_timestamp="${version}-${timestamp}"
echo "Version with timestamp: $version_with_timestamp"
echo "VERSION=$version" >> $GITHUB_ENV
echo "VERSION_WITH_TIMESTAMP=$version_with_timestamp" >> $GITHUB_ENV
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Docker Build & Push
run: |
cd examples/[email protected]/word-count
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/word-count:$VERSION_WITH_TIMESTAMP --build-arg VERSION=$VERSION .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/word-count:$VERSION_WITH_TIMESTAMP