fix(CI): Check if PR exists before push.

This commit is contained in:
Terry Geng 2020-07-13 10:52:47 +08:00
parent 46cb0387fc
commit 936f841841
No known key found for this signature in database
GPG Key ID: F982F8EA1DF720E7

View File

@ -2,11 +2,19 @@ kind: pipeline
type: docker type: docker
name: deployement name: deployement
volumes:
- name: repo
host:
path: /media/raid5/data/packages/repos/apt/botamusique/
steps: steps:
- name: build-web - name: build-web
image: node image: node
commands: commands:
- (cd web && npm install && npm run build) - (cd web && npm install && npm run build)
when:
event:
- push
- name: push-translation - name: push-translation
image: python:3 image: python:3
@ -29,6 +37,9 @@ steps:
commands: commands:
- pip3 install jinja2 - pip3 install jinja2
- (cd templates/ && ./translate.py) - (cd templates/ && ./translate.py)
when:
event:
- push
- name: deploy-testing - name: deploy-testing
image: debian image: debian
@ -111,11 +122,6 @@ steps:
event: event:
- tag - tag
volumes:
- name: repo
host:
path: /media/raid5/data/packages/repos/apt/botamusique/
trigger: trigger:
event: event:
exclude: exclude:
@ -124,7 +130,7 @@ trigger:
--- ---
kind: pipeline kind: pipeline
type: docker type: docker
name: cron name: translation
steps: steps:
- name: fetch-translation - name: fetch-translation
image: debian image: debian
@ -141,23 +147,23 @@ steps:
- | - |
if git fetch origin bot-traduora; then if git fetch origin bot-traduora; then
git branch bot-traduora FETCH_HEAD git branch bot-traduora FETCH_HEAD
CREATE_PR=false
else else
git branch bot-traduora git branch bot-traduora
CREATE_PR=true
fi fi
- git checkout bot-traduora - git checkout bot-traduora
- (cd lang/ && ./sync_translation.py --client $TRADUORA_R_CLIENT --secret $TRADUORA_R_SECRET --fetch) - (cd lang/ && ./sync_translation.py --client $TRADUORA_R_CLIENT --secret $TRADUORA_R_SECRET --fetch)
- git add lang/* - git add lang/*
- git status - git status
- | - |
if (GIT_COMMITTER_NAME='Traduora Bot' GIT_COMMITTER_EMAIL='noreply@azlux.fr' git commit -m 'Bot: Update translation' --author "Traduora Bot <noreply@azlux.fr>"); then if GIT_COMMITTER_NAME='Traduora Bot' GIT_COMMITTER_EMAIL='noreply@azlux.fr' git commit -m 'Bot: Update translation' --author "Traduora Bot <noreply@azlux.fr>"; then
git remote set-url origin https://azlux:$GITHUB_API@github.com/azlux/botamusique/
git push origin bot-traduora git push origin bot-traduora
sleep 2 sleep 2
GITHUB_USER="azlux" GITHUB_TOKEN="$GITHUB_API" hub pull-request -m "Bot: TRADUORA Update" if $CREATE_PR; then GITHUB_USER="azlux" GITHUB_TOKEN="$GITHUB_API" hub pull-request -m "Bot: TRADUORA Update"; fi
fi fi
trigger: trigger:
event: event:
- cron include:
cron: - push
- auto-fetch-lang