-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (80 loc) · 3.97 KB
/
deploy-to-ifrs.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
81
name: Deploy to IFRS
on:
push:
branches:
- main
jobs:
DeployFrontend:
runs-on: ubuntu-latest
steps:
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.IFRS_SSH_KEY }}
known_hosts: ${{ secrets.IFRS_SSH_HOST }}
if_key_exists: fail
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: export TZ=America/Sao_Paulo
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "GitHub Actions from WyeWorks"
- run: git remote add ifrs-frontend [email protected]:ifrscanoas/richard-burton/frontend.git
- run: git fetch ifrs-frontend
# Splits the repo so we can push only the frontend folder
- run: git subtree split -P frontend -b stage-release
- run: git checkout stage-release
# Squashes the whole branch into a single temporary commit
- run: git reset --soft $(git rev-list --max-parents=0 stage-release)
- run: git commit --amend -m "Temporary Commit"
# Generates a diff between the current branch and the IFRS remote
- run: git diff ifrs-frontend/stage > changes.diff
# Rebases the current branch with the IFRS remote to ensure fast-forward merge in the IFRS remote
- run: git pull --rebase ifrs-frontend stage -X theirs
- run: git reset --soft ifrs-frontend/stage
# Applies the diff generated before, so deletions are kept
- run: git apply --reject changes.diff || echo "Patch partially applied with .rej files generated." && cat *.rej
- run: git add . -A
# Ommits files that must not be synced with the ones in the IFRS remote
- run: git restore --staged .gitignore Dockerfile .dockerignore .gitlab-ci.yml .ci '*rej' '*diff' '*gitkeep'
# Commits and push a single release commit
- run: git status
- run: git commit --amend -m "Release to Stage `TZ=America/Sao_Paulo date '+%d %b %Y %T São Paulo (UTC%Z)'`"
- run: git push -f ifrs-frontend stage-release
DeployBackend:
runs-on: ubuntu-latest
steps:
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.IFRS_SSH_KEY }}
known_hosts: ${{ secrets.IFRS_SSH_HOST }}
if_key_exists: fail
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: export TZ=America/Sao_Paulo
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "GitHub Actions from WyeWorks"
- run: git remote add ifrs-backend [email protected]:ifrscanoas/richard-burton/backend.git
- run: git fetch ifrs-backend
# Splits the repo so we can push only the backend folder
- run: git subtree split -P backend -b stage-release
- run: git checkout stage-release
# Squashes the whole branch into a single temporary commit
- run: git reset --soft $(git rev-list --max-parents=0 stage-release)
- run: git commit --amend -m "Temporary Commit"
# Generates a diff between the current branch and the IFRS remote
- run: git diff ifrs-backend/stage > changes.diff
# Rebases the current branch with the IFRS remote to ensure fast-forward merge in the IFRS remote
- run: git pull --rebase ifrs-backend stage -X theirs
- run: git reset --soft ifrs-backend/stage
# Applies the diff generated before, so deletions are kept
- run: git apply --reject changes.diff || echo "Patch partially applied with .rej files generated." && cat *.rej
- run: git add . -A
# Ommits files that must not be synced with the ones in the IFRS remote
- run: git restore --staged .gitignore Dockerfile .dockerignore .gitlab-ci.yml .ci '*rej' '*diff' '*gitkeep'
# Commits and push a single release commit
- run: git status
- run: git commit --amend -m "Release to Stage `TZ=America/Sao_Paulo date '+%d %b %Y %T São Paulo (UTC%Z)'`"
- run: git push -f ifrs-backend stage-release