-
Notifications
You must be signed in to change notification settings - Fork 2
38 lines (38 loc) · 1.49 KB
/
docker-onpush.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: Push to DockerHub
on: [ push ]
env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
jobs:
push-to-docker-hub:
runs-on: ubuntu-latest
if: ${{ contains(github.event.head_commit.message, '#dockerpush') }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
cache: gradle
- name: docker login
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d--%M-%S')"
- name: Code build
run: ./gradlew build --no-daemon -x test -x check
- name: Docker build
run: docker build . --file Dockerfile --tag $DOCKER_USER/${{ github.event.repository.name }}:${{ steps.date.outputs.date }}
- name: Tag with latest
if: ${{ contains(github.event.head_commit.message, '#latest') }}
run: docker tag $DOCKER_USER/${{ github.event.repository.name }}:${{ steps.date.outputs.date }} $DOCKER_USER/${{ github.event.repository.name }}:latest
- name: Docker push
run: docker push --all-tags $DOCKER_USER/${{ github.event.repository.name }}
- name: Call Portainer
uses: fjogeleit/http-request-action@v1
if: ${{ contains(github.event.head_commit.message, '#latest') }}
with:
url: ${{ secrets.WEBHOOK_URL }}
method: 'POST'
timeout: 30000