-
Notifications
You must be signed in to change notification settings - Fork 11
122 lines (92 loc) · 4.86 KB
/
backend.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Backend Build and Publish Docker Image
on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x ./backend/gradlew
- name: Build with Gradle
run: ./backend/gradlew -p ./backend build --stacktrace
docker:
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
needs: build
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
cache: 'gradle'
# - name: Login to GitHub Packages Docker Registry
# uses: docker/login-action@v3
# with:
# registry: docker.pkg.github.com
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GH_PACKAGES_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Grant execute permission for gradlew
run: chmod +x ./backend/gradlew
- name: Retrieve branch or tag name
id: refvar
run: echo "::set-output name=gitRefName::${GITHUB_REF#refs/*/}"
### Docker Hub
- name: Push API Docker image (tag) to Docker Hub
if: startsWith(github.ref, 'refs/tags/')
run: ./backend/gradlew -p ./backend :dev-feed-api:jib -Djib.to.image="registry.hub.docker.com/rm3l/dev-feed-api:${{ steps.refvar.outputs.gitRefName }}"
- name: Push latest API Docker image (master) to Docker Hub
if: github.ref == 'refs/heads/master'
run: ./backend/gradlew -p ./backend :dev-feed-api:jib -Djib.to.image="registry.hub.docker.com/rm3l/dev-feed-api:latest"
- name: Push discoverdev.io crawler Docker image (tag) to Docker Hub
if: startsWith(github.ref, 'refs/tags/')
run: ./backend/gradlew -p ./backend :crawlers:dev-feed-crawler-discoverdev_io:jib -Djib.to.image="registry.hub.docker.com/rm3l/dev-feed-crawler-discoverdev_io:${{ steps.refvar.outputs.gitRefName }}"
- name: Push latest discoverdev.io Docker image (master) to Docker Hub
if: github.ref == 'refs/heads/master'
run: ./backend/gradlew -p ./backend :crawlers:dev-feed-crawler-discoverdev_io:jib -Djib.to.image="registry.hub.docker.com/rm3l/dev-feed-crawler-discoverdev_io:latest"
- name: Push engineeringblogs.xyz crawler Docker image (tag) to Docker Hub
if: startsWith(github.ref, 'refs/tags/')
run: ./backend/gradlew -p ./backend :crawlers:dev-feed-crawler-engineeringblogs_xyz:jib -Djib.to.image="registry.hub.docker.com/rm3l/dev-feed-crawler-engineeringblogs_xyz:${{ steps.refvar.outputs.gitRefName }}"
- name: Push latest engineeringblogs.xyz Docker image (master) to Docker Hub
if: github.ref == 'refs/heads/master'
run: ./backend/gradlew -p ./backend :crawlers:dev-feed-crawler-engineeringblogs_xyz:jib -Djib.to.image="registry.hub.docker.com/rm3l/dev-feed-crawler-engineeringblogs_xyz:latest"
- name: Push rm3l.org crawler Docker image (tag) to Docker Hub
if: startsWith(github.ref, 'refs/tags/')
run: ./backend/gradlew -p ./backend :crawlers:dev-feed-crawler-rm3l_org:jib -Djib.to.image="registry.hub.docker.com/rm3l/dev-feed-crawler-rm3l_org:${{ steps.refvar.outputs.gitRefName }}"
- name: Push latest rm3l.org Docker image (master) to Docker Hub
if: github.ref == 'refs/heads/master'
run: ./backend/gradlew -p ./backend :crawlers:dev-feed-crawler-rm3l_org:jib -Djib.to.image="registry.hub.docker.com/rm3l/dev-feed-crawler-rm3l_org:latest"
# Legacy image is kept for backward compatibility, and will get removed in a near future
- name: Push API Docker legacy image (tag) to Docker Hub
if: startsWith(github.ref, 'refs/tags/')
run: ./backend/gradlew -p ./backend :dev-feed-api:jib -Djib.to.image="registry.hub.docker.com/rm3l/dev-feed:${{ steps.refvar.outputs.gitRefName }}"
- name: Push latest API legacy Docker image (master) to Docker Hub
if: github.ref == 'refs/heads/master'
run: ./backend/gradlew -p ./backend :dev-feed-api:jib -Djib.to.image="registry.hub.docker.com/rm3l/dev-feed:latest"