-
-
Notifications
You must be signed in to change notification settings - Fork 230
80 lines (66 loc) · 2.73 KB
/
update-base.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
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
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