-
Notifications
You must be signed in to change notification settings - Fork 1
38 lines (38 loc) · 1.45 KB
/
build.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
name: Build
on: [ push ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Get tag or branch
id: get_tag_or_branch
run: |
if echo $GITHUB_REF | grep -Eq '^refs\/tags\/.*'; then
echo "TAG_OR_BRANCH=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "TAG_OR_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
fi
- name: Gradle build
env:
GRADLE_CLI_OPTS: "-Dversion=${{steps.get_tag_or_branch.outputs.TAG_OR_BRANCH}}"
run: "chmod +x ./gradlew && ./gradlew ${GRADLE_CLI_OPTS} dockerBuild"
- name: Login to DockerHub
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags')
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker images
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags')
env:
TAG_OR_BRANCH: ${{steps.get_tag_or_branch.outputs.TAG_OR_BRANCH}}
run: |
docker tag faforever/faf-telemetry-server:latest faforever/faf-telemetry-server:${TAG_OR_BRANCH}
docker push faforever/faf-telemetry-server:${TAG_OR_BRANCH}