-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (42 loc) · 1.62 KB
/
docker-publish.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
name: Docker
on:
push:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
# To compare changes between the current commit and the last pushed remote commit set `since_last_remote_commit: true`. e.g
with:
# since_last_remote_commit: true
# files: **
files_ignore: .github/**
- name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
USERNAME: ${{secrets.USERNAME}}
PASSWORD: ${{secrets.PASSWORD}}
run: |
docker login -u ${USERNAME} -p ${PASSWORD}
for file in `echo ${ALL_CHANGED_FILES}|tr " " "\n" | sort |uniq`; do
CHANGEFOLDER=$(echo ${file}|awk -F"/" '{print $1}')
VERSION=$(grep -w VERSION ${CHANGEFOLDER}/Dockerfile |awk -F":" '{print $2}')
echo ${VERSION}
IMAGENAME=$(echo pilgrima/${CHANGEFOLDER}:${VERSION})
echo ${IMAGENAME}
docker buildx build -t ${IMAGENAME} ${CHANGEFOLDER}
docker push ${IMAGENAME}
docker tag ${IMAGENAME} $(echo pilgrima/${CHANGEFOLDER}:latest)
docker push $(echo pilgrima/${CHANGEFOLDER}:latest)
done