-
Notifications
You must be signed in to change notification settings - Fork 3
64 lines (51 loc) · 1.92 KB
/
docker-build.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
name: Docker Image Push (on commit and base image update)
on:
push:
branches: [ "master" ]
schedule:
- cron: "15 4 */3 * *"
env:
IMAGE_OWNER: kimbtechnologies
IMAGE_NAME: telegrambot
BASE_IMAGE: library/php:cli-alpine
jobs:
build:
runs-on: ubuntu-latest
steps:
# Init and check
- name: Access to repository contents
uses: actions/checkout@v4
- name: Check for new baseimage
id: check
uses: lucacome/docker-image-update-checker@v1
with:
base-image: "${{env.BASE_IMAGE}}"
image: "${{env.IMAGE_OWNER}}/${{env.IMAGE_NAME}}:latest"
if: github.event_name != 'push'
# Build image
- name: Build the Docker image
run: docker build . --file "Dockerfile" --tag "$IMAGE_OWNER/$IMAGE_NAME:latest"
if: ${{ (github.event_name == 'push') || (steps.check.outputs.needs-updating == 'true') }}
# Push latest tag
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
if: ${{ (github.event_name == 'push') || (steps.check.outputs.needs-updating == 'true') }}
- name: Push to DockerHub
run: docker push "$IMAGE_OWNER/$IMAGE_NAME:latest"
if: ${{ (github.event_name == 'push') || (steps.check.outputs.needs-updating == 'true') }}
# Version tags to push
- name: Tag and push versions
if: ${{ (github.event_name == 'push') || (steps.check.outputs.needs-updating == 'true') }}
run: |
cat VERSION | while read TAG; do
if [[ $TAG =~ ^#.* ]] ; then
echo "Skipping $TAG";
else
echo "Tagging image as $TAG and pushing";
docker tag "$IMAGE_OWNER/$IMAGE_NAME:latest" "$IMAGE_OWNER/$IMAGE_NAME:$TAG"
docker push "$IMAGE_OWNER/$IMAGE_NAME:$TAG"
fi;
done;