-
Notifications
You must be signed in to change notification settings - Fork 51
48 lines (43 loc) · 1.45 KB
/
ci.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
name: Build and update image
on:
push:
branches:
- master
- generator*
paths:
- subnet/deployment-generator/**
tags:
- '*'
workflow_dispatch: #allow manual trigger to workflow
jobs:
build_and_push_image:
name: build and push image to registry
runs-on: ubuntu-latest
environment: DockerHub
defaults:
run:
working-directory: subnet/deployment-generator
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Docker login
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- name: Determine Docker Image Name
id: image
run: |
if [[ "${{github.ref_name}}" == "master" ]]; then
echo "name=xinfinorg/subnet-generator:latest" >> $GITHUB_OUTPUT
else
echo "name=xinfinorg/subnet-generator:${{github.ref_name}}" >> $GITHUB_OUTPUT
fi
- name: Build and push image
run: |
docker build . --file docker/Dockerfile \
--build-arg SUBNET_BRANCH=${{ steps.commit.outputs.commit}} \
--build-arg IMAGE_NAME=${{ steps.image.outputs.name }} \
--tag ${{ steps.image.outputs.name }}
docker push ${{ steps.image.outputs.name }}