Skip to content

Commit 2e0f287

Browse files
Williangalvanipatrickelectric
authored andcommitted
CI: create deploy.yml
1 parent 6519add commit 2e0f287

2 files changed

Lines changed: 49 additions & 22 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Deployment Workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout Code
14+
uses: actions/checkout@v2
15+
with:
16+
submodules: recursive
17+
18+
- name: Setup Environment
19+
run: |
20+
pip install jinja2
21+
generate/generate-python.py --output-dir=brping
22+
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
23+
git fetch origin deployment
24+
git config user.email "support@bluerobotics.com"
25+
git config user.name "BlueRobotics-CI"
26+
27+
- name: install and test
28+
run: |
29+
echo "installing package..."
30+
pip install . --user
31+
32+
echo "testing message api..."
33+
python brping/pingmessage.py
34+
35+
36+
- name: Generate and Commit Files
37+
run: |
38+
ci/deploy.sh
39+
40+
- name: Commit Changes
41+
run: |
42+
git commit -m "update autogenerated files for $(git rev-parse HEAD@{2})" || exit 0
43+
44+
- name: Push changes
45+
uses: ad-m/github-push-action@master
46+
with:
47+
github_token: ${{ secrets.GITHUB_TOKEN }}
48+
branch: deployment

ci/deploy.sh

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@
33
# source helper functions
44
source ci/ci-functions.sh
55

6-
# thank you https://stackoverflow.com/a/47441734
7-
# this is requried to be able to checkout branches after fetching
8-
test git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
9-
test git fetch origin deployment
10-
116
# TODO make test() work with | pipe
127
cat ci/deploy-whitelist | xargs git add -f
138
# commit generated files if necessary, it's ok if commit fails
14-
git commit -m temporary-commit
9+
git commit -m "temporary commit"
1510
# move to deployment branch
1611
test git checkout deployment
1712
test rm -rf *
@@ -22,19 +17,3 @@ cat ci/deploy-whitelist | xargs git checkout HEAD@{1}
2217
test git --no-pager diff --staged
2318
# unstage the whitelist
2419
test git rm -f ci/deploy-whitelist
25-
26-
if [ "${TRAVIS}" == "true" ]; then
27-
test git config user.email "support@bluerobotics.com"
28-
test git config user.name "BlueRobotics-CI"
29-
fi
30-
31-
git commit -m "update autogenerated files for $(git rev-parse HEAD@{2})" || return 0
32-
33-
# deploy
34-
if [ ! -z ${TRAVIS_PULL_REQUEST} ] && [ ${TRAVIS_PULL_REQUEST} == "false" ]; then
35-
echob "Updating deployment branch.."
36-
test git remote set-url origin https://${GITHUB_TOKEN}@github.com/bluerobotics/ping-python
37-
test git push origin
38-
else
39-
echob "PR detected, no deployment will be done."
40-
fi

0 commit comments

Comments
 (0)