-
Notifications
You must be signed in to change notification settings - Fork 122
47 lines (37 loc) · 1.31 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
name: docker
on:
push:
branches:
- develop
- "release*"
jobs:
build_and_push_x86_64:
runs-on: ubuntu-latest
env:
REGISTRY: docker.io
USERNAME: dhiway
IMAGE_NAME: ${{ github.event.repository.name }}
COMMIT_SHA: ${{ github.sha }}
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USERNAME }}
password: "${{ secrets.DOCKER_PASSWORD }}"
- name: Build and Push to Docker Hub
run: |
# Get the branch name
DOCKER_BRANCH=${{ github.ref }}
DOCKER_BRANCH=${DOCKER_BRANCH/refs\/heads\//}
export DOCKER_BUILDKIT=1
docker build --no-cache --file docker/Dockerfile --tag ${{ env.IMAGE_NAME}}:$DOCKER_BRANCH .
docker tag \
${{ env.IMAGE_NAME}}:$DOCKER_BRANCH \
${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME}}:${{ env.COMMIT_SHA}} \
&& docker tag \
${{ env.IMAGE_NAME}}:$DOCKER_BRANCH \
${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME}}:$DOCKER_BRANCH
docker push ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME}}:$DOCKER_BRANCH