-
Notifications
You must be signed in to change notification settings - Fork 2
151 lines (115 loc) · 4.44 KB
/
ci.yaml
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
name: CI
on: [push, pull_request]
jobs:
generate-app-name:
name: Generate App name
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Generate App name
id: generate_app_name
run: |
repo_name=${{ github.event.repository.name }}
echo $repo_name
lowercase_repo_name=${repo_name,,}
echo $lowercase_repo_name
name_spaces=$(echo $lowercase_repo_name | sed 's/-/ /g' | sed 's/\w\+/\L\u&/g')
echo $name_spaces
echo "::set-output name=app-lowercase::$lowercase_repo_name"
echo "::set-output name=app-name::$name_spaces"
outputs:
app-lowercase: ${{ steps.generate_app_name.outputs.app-lowercase }}
app-name: ${{ steps.generate_app_name.outputs.app-name }}
test-docker:
name: Test Docker build
runs-on: ubuntu-latest
needs: generate-app-name
steps:
- uses: actions/checkout@v2
- name: Build docker image
run: docker build app --tag ${{needs.generate-app-name.outputs.app-lowercase}}:latest
release-on-github:
name: Release on Github
runs-on: ubuntu-latest
needs: test-docker
if: github.ref == 'refs/heads/master' && github.event.repository.owner.name == 'pollination-apps'
steps:
- uses: actions/checkout@v2
- name: set up node
uses: actions/[email protected]
with:
node-version: 14.2.0
- name: install semantic-release
run: npm install @semantic-release/exec
- name: run semantic release
id: new_release
run: |
nextRelease="`npx semantic-release@^17.0.0 --dryRun | grep -oP 'Published release \K.*? ' || true`"
npx semantic-release@^17.0.0
echo "::set-output name=tag::$nextRelease"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
tag: ${{ steps.new_release.outputs.tag }}
deploy-to-staging:
name: Deploy to Pollination Staging
runs-on: ubuntu-latest
needs: release-on-github
if: ${{github.ref == 'refs/heads/master' && github.event.repository.owner.name == 'pollination-apps' && contains(needs.release-on-github.outputs.tag, '.')}}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Get Job Context
id: get-context
run: |
TAG=$(git describe --tags | sed 's/v//')
echo "Releasing tag: ${TAG:?}"
echo "::set-output name=tag::$TAG"
- name: install pollination-apps
run: pip install -U pollination-apps
- name: deploy to staging
run: |
TAG=$(echo "${TAG:?}" | sed 's/[[:space:]]//g')
TAG=${TAG%%-*}
echo pollination-apps deploy app --tag $TAG --environment staging --public --message "${{github.event.commits[0].message}}"
pollination-apps deploy app --tag $TAG --environment staging --public --message "${{github.event.commits[0].message}}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
POLLINATION_TOKEN: ${{ secrets.POLLINATION_STAGING_TOKEN }}
TAG: ${{ steps.get-context.outputs.tag }}
deploy-to-pollination:
name: Deploy to Pollination
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/production' && github.event.repository.owner.name == 'pollination-apps'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Get Job Context
id: get-context
run: |
TAG=$(git describe --tags | sed 's/v//')
echo "Releasing tag: ${TAG:?}"
echo "::set-output name=tag::$TAG"
- name: install pollination-apps
run: pip install -U pollination-apps
- name: deploy to production
run: |
TAG=$(echo "${TAG:?}" | sed 's/[[:space:]]//g')
TAG=${TAG%%-*}
echo pollination-apps deploy app --tag $TAG --public --message "${{github.event.commits[0].message}}"
pollination-apps deploy app --tag $TAG --public --message "${{github.event.commits[0].message}}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
POLLINATION_TOKEN: ${{ secrets.POLLINATION_LADYBUGBOT_TOKEN }}
TAG: ${{ steps.get-context.outputs.tag }}