Skip to content

Automation base image updater #183

Automation base image updater

Automation base image updater #183

Workflow file for this run

name: Automation base image updater
on:
schedule:
# Run at the end of every day
- cron: "0 0 * * *"
jobs:
update-base:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: 'master'
- name: Update base image
run: |
old_base_img=$(bash <(curl -s https://raw.githubusercontent.com/budtmo/sldi/v0.2/dockerfile_base.sh) get Appium/Dockerfile)
echo "OLD_BASE=${old_base_img}" >> $GITHUB_ENV
IFS=':' read -r -a base <<< "${old_base_img}"
echo ${base[@]}
bash <(curl -s https://raw.githubusercontent.com/budtmo/sldi/v0.2/sldi.sh) ${base[0]} ${base[1]} focal focal-
if [ -f tmp-sldi.txt ]; then
new_base_img=$(cat tmp-sldi.txt)
echo "NEW_BASE=${new_base_img}" >> $GITHUB_ENV
bash <(curl -s https://raw.githubusercontent.com/budtmo/sldi/v0.2/dockerfile_base.sh) replace ${old_base_img} ${new_base_img} Appium/Dockerfile
echo "ANY_CHANGES=true" >> "$GITHUB_ENV"
else
echo "There is no changes, next steps will be skipped"
echo "ANY_CHANGES=false" >> "$GITHUB_ENV"
fi
- name: Prepare tag and release note
if: env.ANY_CHANGES == 'true'
run: |
git fetch --all --tags
new_tag=$(bash <(curl -s https://raw.githubusercontent.com/budtmo/sldi/v0.2/git_tag_creator.sh) p)
echo "NEW_RELEASE_TAG=${new_tag}" >> $GITHUB_ENV
- name: Commit changes and tag
if: env.ANY_CHANGES == 'true'
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: 'master'
commit_message: Update base image from ${{ env.OLD_BASE }} to ${{ env.NEW_BASE }}
tagging_message: ${{ env.NEW_RELEASE_TAG }}
- name: Release new version
if: env.ANY_CHANGES == 'true'
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.NEW_RELEASE_TAG }}
name: ${{ env.NEW_RELEASE_TAG }}
body: |
Changes:
- Update base image from ${{ env.OLD_BASE }} to ${{ env.NEW_BASE }}
draft: false
prerelease: false
- name: Build docker image
if: env.ANY_CHANGES == 'true'
run: ./app.sh build ${{ env.NEW_RELEASE_TAG }}
- name: Test docker image
if: env.ANY_CHANGES == 'true'
run: ./app.sh test ${{ env.NEW_RELEASE_TAG }}
- name: Push docker image
if: env.ANY_CHANGES == 'true'
run: |
docker login -u=${{secrets.DOCKER_USERNAME}} -p=${{secrets.DOCKER_PASSWORD}}
./app.sh push ${{ env.NEW_RELEASE_TAG }}
docker logout