Skip to content

Build docker images #77

Build docker images

Build docker images #77

Workflow file for this run

name: Build docker images
on:
workflow_dispatch:
schedule:
# Every day at 17:30, we udpdate images
- cron: '30 17 * * *'
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and publish images
run: |
npm install -g doctoc
./update "${{ secrets.DOCKERHUB_USERNAME }}/decidim"
ls *.versions
for file in $(find bundle -type f -name "Dockerfile-*"); do
default_tag=$(basename "$file" | sed 's/^Dockerfile-//')
default_destination="${{ secrets.DOCKERHUB_USERNAME }}/decidim:$default_tag"
stable_version=$(echo "$default_tag" | cut -d'-' -f1)
echo "$stable_version: build 'decidim/$default_tag' with $file"
docker build -t $default_destination -f "$file" ./bundle
if [ -f "$stable_version.versions" ]; then
while read version; do
destination_tag=$(echo $default_tag | sed -e "s/$stable_version/$version/")
destination="${{ secrets.DOCKERHUB_USERNAME }}/decidim:$destination_tag"
docker tag $default_destination $destination
docker push $destination
done < "$stable_version.versions"
else
echo "No $stable_version.versions file, push to default destination"
docker push $default_destination
fi
if [ $default_tag == "develop-dev" ]; then
latest="${{ secrets.DOCKERHUB_USERNAME }}/decidim:latest"
docker tag $default_destination $latest
docker push $latest
fi
done
- name: Commit and push changes
run: |
git config --global user.name "Github Actions"
git config --global user.email "actions@github.com"
git add .
git diff-index --quiet HEAD || git commit -m "Update files from update script"
git push