-
Notifications
You must be signed in to change notification settings - Fork 4
76 lines (65 loc) · 2.03 KB
/
build-image-bot.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
69
70
71
72
73
74
75
76
name: Build and Push Bot Docker Image
on:
push:
branches:
- main
tags:
- '*'
paths:
- 'Dockerfile_bot'
- 'src/bot/**'
- 'requirements-bot.txt'
pull_request:
paths:
- 'Dockerfile_bot'
- 'src/bot/**'
- 'requirements-bot.txt'
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get the latest Git tag
id: get_tag
run: |
TAG=$(git describe --tags --abbrev=0)
echo "Latest tag is $TAG"
echo "LATEST_TAG=$TAG" >> $GITHUB_ENV
- name: Set short git commit SHA
id: get_sha
run: |
SHORT_SHA=$(git rev-parse --short ${{ github.sha }})
echo "Short commit SHA is $SHORT_SHA"
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV
- name: Confirm git commit SHA and tag variables
run: |
if [ -z "${{ env.SHORT_SHA }}" ] || [ -z "${{ env.LATEST_TAG }}" ]; then
echo "Error: One of SHORT_SHA, LATEST_TAG is empty"
exit 1
fi
# Setup Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# Login to Docker Hub
- name: Login to DockerHub
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Build and push bot image
- name: Build and push bot Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile_bot
push: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }}
tags: |
olegeech/mvcr-application-checker:bot-latest
olegeech/mvcr-application-checker:bot-${{ env.LATEST_TAG }}
build-args: |
BASE_VERSION=${{ env.LATEST_TAG }}
GIT_COMMIT=${{ env.SHORT_SHA }}