Checkout the bitnami repo and build images #618
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="2024-08-24" | |
# 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/5417b50fe5b4667920297298c1887e4b37faa747/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 buildx build "6/debian-12" \ | |
-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 |