-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (80 loc) · 3.65 KB
/
daily.yaml
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: 'Checkout the bitnami repo and build images'
on:
schedule:
- cron: '0 1 * * *'
workflow_dispatch:
jobs:
merge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Merge upstream
run: |
export since="1 day ago"
# Checkout the repository
echo "*** Configuring the local git ***"
git config --global user.email "[email protected]"
git config --global user.name "wordlift-bot"
git config --global advice.detachedHead false
## Checkout the tags
echo "*** Cloning the original bitnami/containers repo ***"
git clone \
--shallow-since="$since" \
--filter=blob:none \
--sparse \
https://github.com/bitnami/containers ;
cd containers ;
git sparse-checkout set bitnami/wordpress-nginx ;
cd bitnami/wordpress-nginx
# Build the images
echo ${{ secrets.GITHUB_TOKEN }} | docker login --username ${{ github.repository_owner }} --password-stdin ghcr.io
echo ${{ secrets.DOCKER_TOKEN }} | docker login --username ${{ secrets.DOCKER_USER }} --password-stdin
logs=$(git log --reverse --since="$since" --pretty=tformat:"%C(auto)%h %s" --grep="\[bitnami/wordpress-nginx\] [R|r]elease" --author [email protected] --author [email protected] --author [email protected] || true)
while IFS= read -r log; do
[ -z "$log" ] && continue
commit=$(echo $log | cut -f1 -d' ')
tag=$(echo $log | cut -f4 -d' ')
echo "*** Log: $log ***"
echo "*** Commit: $commit ***"
echo "*** Tag: $tag ***"
echo "*** Checking out commit $commit ***"
git checkout $commit
# Apply the patch
echo "*** Applying patch ***"
curl -s https://gist.githubusercontent.com/ziodave/20ab49f5ea2e6e500255c7e5ff1fd5e2/raw/306748d587772a00f32b7288b3d081890b5e7232/1.patch | patch -p1
echo "*** Preparing tags ***"
version=$(echo $tag | cut -d '-' -f1)
echo "*** Version: $version ***"
major=$(echo $version | cut -d'.' -f1)
echo "*** Major: $major ***"
os=$(echo $tag | cut -d '-' -f2)
echo "*** OS: $os ***"
osrel=$(echo $tag | cut -d '-' -f3)
echo "*** OS Rel: $osrel ***"
# Ex: 6
tag0="wordlift/wordpress-nginx:$major"
echo "*** Tag 0: $tag0 ***"
# Ex: 6-debian-11
tag1="wordlift/wordpress-nginx:$major-$os-$osrel"
echo "*** Tag 1: $tag1 ***"
# Ex: 6.0.0
tag2="wordlift/wordpress-nginx:$version"
echo "*** Tag 2: $tag2 ***"
# Ex: 6.0.0-debian-11-r0
tag3="wordlift/wordpress-nginx:$tag"
echo "*** Tag 3: $tag3 ***"
## Tag the images
echo "*** Building image in $major/$os-$osrel with tags $tag0, $tag1, $tag2 and $tag3 ***"
docker build "$major/$os-$osrel" \
-t ghcr.io/$tag0 -t ghcr.io/$tag1 -t ghcr.io/$tag2 -t ghcr.io/$tag3 \
-t $tag0 -t $tag1 -t $tag2 -t $tag3
docker push ghcr.io/$tag0
docker push ghcr.io/$tag1
docker push ghcr.io/$tag2
docker push ghcr.io/$tag3
docker push $tag0
docker push $tag1
docker push $tag2
docker push $tag3
git reset --hard
done <<< $logs