-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (42 loc) · 1.41 KB
/
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
name: Docker build and release
on:
workflow_run:
workflows: ["Server build"]
types:
- completed
push:
branches:
- main
paths:
- '.github/workflows/docker.yml'
- 'Dockerfile'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and tag Docker image
run: |
git fetch --tags
version=$(echo $(git tag --sort=-creatordate | head -n 1))
version=${version#v}
echo $version
docker buildx build -t ${{ secrets.DOCKER_USERNAME }}/photron:$version . --platform linux/arm64/v8,linux/amd64 --push
echo 'Version built!'
docker tag ${{ secrets.DOCKER_USERNAME }}/photron:$version ${{ secrets.DOCKER_USERNAME }}/photron:latest
echo 'Version retagged!'
- name: Push image to Docker Hub
run: |
version=$(echo $(git tag --sort=-creatordate | head -n 1))
version=${version#v}
echo $version
docker push ${{ secrets.DOCKER_USERNAME }}/photron:$version
docker push ${{ secrets.DOCKER_USERNAME }}/photron:latest