-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (91 loc) · 3.19 KB
/
maven_docker.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: maven and docker
on:
push:
branches: [ main, dev ]
tags: [ v* ]
pull_request:
branches: [ main, dev ]
jobs:
build:
name: compile maven package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'adopt'
- name: maven-settings
uses: s4u/maven-settings-action@v3.0.0
with:
servers: '[{"id": "edirom", "username": "${github.actor}", "password": "${GITHUB_TOKEN}"},{"id": "teic", "username": "${github.actor}", "password": "${GITHUB_TOKEN}"}]'
- name: Build with Maven
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn clean package --file pom.xml
- name: Upload Maven build artifact
uses: actions/upload-artifact@v4
with:
name: artifact
path: /home/runner/work/MEIGarage/MEIGarage/target/meigarage.war
docker:
name: build the Docker image
needs: build
runs-on: ubuntu-latest
#don't run docker build on pull request at all
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: artifact
path: artifact/
# use the current user to log into the
# GitHub container registry
- name: Log in to GitHub Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Login against DockerHub registry
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: vifebot
password: ${{ secrets.VIFEBOT_DOCKERHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/edirom/meigarage
edirom/meigarage
flavor: |
latest=${{ github.ref == 'refs/heads/main' }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILDTYPE=github
# Use current README for DockerHub description
- name: Update repo description
uses: peter-evans/dockerhub-description@v4
with:
username: vifebot
password: ${{ secrets.VIFEBOT_DOCKERHUB_TOKEN }}
repository: edirom/meigarage
short-description: ${{ github.event.repository.description }}