-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (66 loc) · 1.99 KB
/
docker-image.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
name: Publish images to Docker Hub
on:
push:
branches: [ develop, tnet, main ]
paths-ignore:
- '.github/**'
workflow_dispatch: # manually triggered
jobs:
build_and_push:
name: Build and push
runs-on: ubuntu-latest
steps:
-
name: Check out the repo
uses: actions/checkout@v2
-
name: Set branch name
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
-
name: Set sha tag
run: |
SHA_TAG=$(git rev-parse --short=12 "${{ github.sha }}")
echo "SHA_TAG=$SHA_TAG" >> $GITHUB_ENV
-
name: Set main branch tag
if: ${{ env.BRANCH == 'main' }}
run: |
echo "ENV_TAG=prod" >> $GITHUB_ENV
-
name: Set rc branch tag
if: ${{ env.BRANCH == 'tnet' }}
run: |
echo "ENV_TAG=tnet" >> $GITHUB_ENV
-
name: Set develop branch tag
if: ${{ env.BRANCH == 'develop' || env.ENV_TAG == '' }}
run: |
echo "ENV_TAG=dev" >> $GITHUB_ENV
-
name: Set environment from manual input
if: ${{ github.event.inputs.environment != '' }}
run: |
echo "ENV_TAG=${{ github.event.inputs.environment }}" >> $GITHUB_ENV
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push image
env:
IMAGE_ID: "3boxlabs/ipfs-pinset-migration"
run: |
EXTRA_TAGS=""
if [[ "${{ env.ENV_TAG }}" == "prod" ]]; then
EXTRA_TAGS="--tag $IMAGE_ID:latest"
fi
docker buildx build . --output 'type=image,push=true' \
--tag $IMAGE_ID:${{ env.ENV_TAG }} \
--tag $IMAGE_ID:${{ env.SHA_TAG }} \
--tag $IMAGE_ID:${{ github.sha }} \
$EXTRA_TAGS