forked from MapComplete/MapComplete
Scripts: make deploy script robust against slashes in branch names
This commit is contained in:
parent
17d7c82d90
commit
68c8e1e237
1 changed files with 14 additions and 6 deletions
|
@ -52,27 +52,35 @@ jobs:
|
||||||
|
|
||||||
- name: Zipping dist file
|
- name: Zipping dist file
|
||||||
run: |
|
run: |
|
||||||
mv dist /tmp/${{ github.ref_name }}
|
BRANCH=$(echo ${{ github.ref_name }} | sed 's/\//-/g')
|
||||||
|
mv dist /tmp/${{ BRANCH }}
|
||||||
cd /tmp
|
cd /tmp
|
||||||
zip ${{ github.ref_name }}.zip -r ${{ github.ref_name }}/*
|
zip ${{ BRANCH }}.zip -r ${{ BRANCH }}/*
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
- name: uploading file
|
- name: uploading file
|
||||||
run: scp /tmp/${{ github.ref_name }}.zip hetzner:/root/staging/
|
run: |
|
||||||
|
BRANCH=$(echo ${{ github.ref_name }} | sed 's/\//-/g')
|
||||||
|
scp /tmp/${BRANCH}.zip hetzner:/root/staging/
|
||||||
|
|
||||||
- name: cleanup files
|
- name: cleanup files
|
||||||
run: rm /tmp/${{ github.ref_name }}.zip && rm -rf /tmp/${{ github.ref_name }}/
|
run: |
|
||||||
|
BRANCH=$(echo ${{ github.ref_name }} | sed 's/\//-/g')
|
||||||
|
rm /tmp/${BRANCH}.zip && r${GITHUB_REF_NAME}m -rf /tmp/${BRANCH}/
|
||||||
|
|
||||||
- name: unzipping remote file
|
- name: unzipping remote file
|
||||||
run: ssh hetzner "cd /root/staging && rm -rf ${{ github.ref_name }} && unzip ${{ github.ref_name }}.zip && rm -rf /root/public/${{ github.ref_name }} && mv /root/staging/${{ github.ref_name }}/ /root/public/ && rm ${{ github.ref_name }}.zip"
|
run: |
|
||||||
|
BRANCH=$(echo ${{ github.ref_name }} | sed 's/\//-/g')
|
||||||
|
ssh hetzner "cd /root/staging && rm -rf ${BRANCH} && unzip ${BRANCH}.zip && rm -rf /root/public/${BRANCH} && mv /root/staging/${BRANCH}/ /root/public/ && rm ${BRANCH}.zip"
|
||||||
|
|
||||||
- name: Comment on the PR
|
- name: Comment on the PR
|
||||||
run: |
|
run: |
|
||||||
|
BRANCH=$(echo ${{ github.ref_name }} | sed 's/\//-/g')
|
||||||
PR_NUMBER=$(echo ${{ github.event.pull_request.number || github.event.issue.number }})
|
PR_NUMBER=$(echo ${{ github.event.pull_request.number || github.event.issue.number }})
|
||||||
if [[ -n "$PR_NUMBER" ]]
|
if [[ -n "$PR_NUMBER" ]]
|
||||||
then
|
then
|
||||||
echo "Found a pull request or issue number, will post to $PR_NUMBER ..."
|
echo "Found a pull request or issue number, will post to $PR_NUMBER ..."
|
||||||
MSG=$(echo "Congratulations! This PR been successfully built and has been deployed. It is (temporarily) available on https://builds.mapcomplete.org/${PR_NUMBER}")
|
MSG=$(echo "Congratulations! This PR been successfully built and has been deployed. It is (temporarily) available on https://builds.mapcomplete.org/${BRANCH}")
|
||||||
BODY="{\"body\": \"$MSG\"}"
|
BODY="{\"body\": \"$MSG\"}"
|
||||||
# Token must have following permissions: issue > read and write
|
# Token must have following permissions: issue > read and write
|
||||||
curl -X POST "https://source.mapcomplete.org/api/v1/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" \
|
curl -X POST "https://source.mapcomplete.org/api/v1/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue