|
| 1 | +# |
| 2 | +# Postfacto, a free, open-source and self-hosted retro tool aimed at helping |
| 3 | +# remote teams. |
| 4 | +# |
| 5 | +# Copyright (C) 2016 - Present Pivotal Software, Inc. |
| 6 | +# |
| 7 | +# This program is free software: you can redistribute it and/or modify |
| 8 | +# |
| 9 | +# it under the terms of the GNU Affero General Public License as |
| 10 | +# |
| 11 | +# published by the Free Software Foundation, either version 3 of the |
| 12 | +# |
| 13 | +# License, or (at your option) any later version. |
| 14 | +# |
| 15 | +# |
| 16 | +# |
| 17 | +# This program is distributed in the hope that it will be useful, |
| 18 | +# |
| 19 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | +# |
| 21 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | +# |
| 23 | +# GNU Affero General Public License for more details. |
| 24 | +# |
| 25 | +# |
| 26 | +# |
| 27 | +# You should have received a copy of the GNU Affero General Public License |
| 28 | +# |
| 29 | +# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 30 | +# |
| 31 | +name: Pipeline |
| 32 | + |
| 33 | +on: [push, pull_request] |
| 34 | + |
| 35 | +jobs: |
| 36 | + ruby-test: |
| 37 | + runs-on: ubuntu-20.04 |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v2 |
| 40 | + - uses: ruby/setup-ruby@v1 |
| 41 | + with: |
| 42 | + ruby-version: .ruby-version |
| 43 | + bundler-cache: true |
| 44 | + working-directory: api |
| 45 | + - run: bundle install |
| 46 | + working-directory: e2e |
| 47 | + - run: bundle exec rake db:create db:migrate |
| 48 | + working-directory: api |
| 49 | + - run: bundle exec rake |
| 50 | + working-directory: api |
| 51 | + |
| 52 | + node-test: |
| 53 | + runs-on: ubuntu-20.04 |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v2 |
| 56 | + - uses: actions/setup-node@v1 |
| 57 | + with: |
| 58 | + node-version: '14.16.1' |
| 59 | + - uses: actions/cache@v2 |
| 60 | + with: |
| 61 | + path: ~/.npm |
| 62 | + key: postfacto-npm-${{ hashFiles('**/package-lock.json') }} |
| 63 | + restore-keys: | |
| 64 | + postfacto-npm-${{ hashFiles('**/package-lock.json') }} |
| 65 | + postfacto-npm- |
| 66 | + - run: npm ci |
| 67 | + working-directory: web |
| 68 | + - run: npm ci |
| 69 | + working-directory: mock-google-server |
| 70 | + - run: npm run lint |
| 71 | + working-directory: web |
| 72 | + - run: npm test |
| 73 | + working-directory: web |
| 74 | + |
| 75 | + e2e-test: |
| 76 | + runs-on: ubuntu-20.04 |
| 77 | + needs: |
| 78 | + - ruby-test |
| 79 | + - node-test |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@v2 |
| 82 | + - uses: ruby/setup-ruby@v1 |
| 83 | + with: |
| 84 | + ruby-version: .ruby-version |
| 85 | + bundler-cache: true |
| 86 | + working-directory: api |
| 87 | + - run: bundle install |
| 88 | + working-directory: e2e |
| 89 | + - uses: actions/setup-node@v1 |
| 90 | + with: |
| 91 | + node-version: '14.16.1' |
| 92 | + - uses: actions/cache@v2 |
| 93 | + with: |
| 94 | + path: ~/.npm |
| 95 | + key: postfacto-npm-${{ hashFiles('**/package-lock.json') }} |
| 96 | + restore-keys: | |
| 97 | + postfacto-npm-${{ hashFiles('**/package-lock.json') }} |
| 98 | + postfacto-npm- |
| 99 | + - run: npm ci |
| 100 | + working-directory: web |
| 101 | + - run: npm ci |
| 102 | + working-directory: mock-google-server |
| 103 | + - run: ./e2e.sh |
| 104 | + |
| 105 | + docker-build: |
| 106 | + runs-on: ubuntu-20.04 |
| 107 | + needs: e2e-test |
| 108 | + steps: |
| 109 | + - uses: actions/checkout@v2 |
| 110 | + - uses: docker/setup-buildx-action@v1 |
| 111 | + - name: Get full tag |
| 112 | + id: full_tag |
| 113 | + run: echo ::set-output name=VERSION::${GITHUB_REF##*/} |
| 114 | + - name: Get major version |
| 115 | + id: versions |
| 116 | + run: | |
| 117 | + echo ::set-output name=MAJOR::$(echo $VERSION | cut -d. -f1) |
| 118 | + echo ::set-output name=MINOR::$(echo $VERSION | cut -d. -f2) |
| 119 | + env: |
| 120 | + VERSION: ${{ steps.full_tag.outputs.VERSION }} |
| 121 | + - uses: docker/login-action@v1 |
| 122 | + if: startsWith(github.ref, 'refs/tags/') |
| 123 | + with: |
| 124 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 125 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 126 | + - uses: docker/build-push-action@v2 |
| 127 | + with: |
| 128 | + push: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 129 | + tags: | |
| 130 | + postfacto/postfacto |
| 131 | + postfacto/postfacto:${{ steps.versions.outputs.MAJOR }} |
| 132 | + postfacto/postfacto:${{ steps.versions.outputs.MAJOR }}.${{ steps.versions.outputs.MINOR }} |
| 133 | + postfacto/postfacto:${{ steps.full_tag.outputs.VERSION }} |
| 134 | +
|
| 135 | + package-build: |
| 136 | + runs-on: ubuntu-20.04 |
| 137 | + needs: e2e-test |
| 138 | + steps: |
| 139 | + - uses: actions/checkout@v2 |
| 140 | + - uses: ruby/setup-ruby@v1 |
| 141 | + with: |
| 142 | + ruby-version: .ruby-version |
| 143 | + bundler-cache: true |
| 144 | + working-directory: api |
| 145 | + - run: bundle pack |
| 146 | + working-directory: api |
| 147 | + - run: rm -rf ./api/vendor/bundle/ |
| 148 | + - uses: actions/setup-node@v1 |
| 149 | + with: |
| 150 | + node-version: '14.16.1' |
| 151 | + - uses: actions/cache@v2 |
| 152 | + with: |
| 153 | + path: ~/.npm |
| 154 | + key: postfacto-npm-${{ hashFiles('**/package-lock.json') }} |
| 155 | + restore-keys: | |
| 156 | + postfacto-npm-${{ hashFiles('**/package-lock.json') }} |
| 157 | + postfacto-npm- |
| 158 | + - run: npm ci |
| 159 | + working-directory: web |
| 160 | + - uses: docker/setup-buildx-action@v1 |
| 161 | + - name: Get full tag |
| 162 | + id: full_tag |
| 163 | + run: echo ::set-output name=VERSION::${GITHUB_REF##*/} |
| 164 | + - name: Helm build |
| 165 | + run: | |
| 166 | + docker run \ |
| 167 | + -v "$GITHUB_WORKSPACE/deployment/helm/":/helm \ |
| 168 | + -w /helm \ |
| 169 | + --entrypoint /helm/build.sh \ |
| 170 | + alpine/helm:3.2.1 $TAG |
| 171 | + env: |
| 172 | + TAG: ${{ steps.full_tag.outputs.VERSION }} |
| 173 | + - name: Package build with dependencies |
| 174 | + run: ./package.sh $TAG |
| 175 | + env: |
| 176 | + TAG: ${{ steps.full_tag.outputs.VERSION }} |
| 177 | + - run: mv package.zip package-vendored.zip |
| 178 | + - uses: actions/upload-artifact@v2 |
| 179 | + with: |
| 180 | + name: Package (including dependencies) |
| 181 | + path: package-vendored.zip |
| 182 | + - run: rm -rf ./api/vendor/ |
| 183 | + - name: Package build without dependencies |
| 184 | + run: ./package.sh $TAG --skip-build |
| 185 | + env: |
| 186 | + TAG: ${{ steps.full_tag.outputs.VERSION }} |
| 187 | + - uses: actions/upload-artifact@v2 |
| 188 | + with: |
| 189 | + name: Package (no dependencies) |
| 190 | + path: package.zip |
| 191 | + - uses: softprops/action-gh-release@v1 |
| 192 | + if: startsWith(github.ref, 'refs/tags/') |
| 193 | + with: |
| 194 | + draft: true |
| 195 | + files: | |
| 196 | + package*.zip |
| 197 | + deployment/helm/postfacto-*.tgz |
| 198 | + env: |
| 199 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 200 | + |
| 201 | + smoke-build: |
| 202 | + runs-on: ubuntu-20.04 |
| 203 | + needs: e2e-test |
| 204 | + steps: |
| 205 | + - uses: actions/checkout@v2 |
| 206 | + - uses: docker/setup-buildx-action@v1 |
| 207 | + - name: Get full tag |
| 208 | + id: full_tag |
| 209 | + run: echo ::set-output name=VERSION::${GITHUB_REF##*/} |
| 210 | + - name: Get major version |
| 211 | + id: versions |
| 212 | + run: | |
| 213 | + echo ::set-output name=MAJOR::$(echo $VERSION | cut -d. -f1) |
| 214 | + echo ::set-output name=MINOR::$(echo $VERSION | cut -d. -f2) |
| 215 | + env: |
| 216 | + VERSION: ${{ steps.full_tag.outputs.VERSION }} |
| 217 | + - uses: docker/login-action@v1 |
| 218 | + if: startsWith(github.ref, 'refs/tags/') |
| 219 | + with: |
| 220 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 221 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 222 | + - uses: docker/build-push-action@v2 |
| 223 | + with: |
| 224 | + context: ./smoke |
| 225 | + file: ./docker/smoke/Dockerfile |
| 226 | + push: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 227 | + tags: | |
| 228 | + postfacto/smoke |
| 229 | + postfacto/smoke:${{ steps.versions.outputs.MAJOR }} |
| 230 | + postfacto/smoke:${{ steps.versions.outputs.MAJOR }}.${{ steps.versions.outputs.MINOR }} |
| 231 | + postfacto/smoke:${{ steps.full_tag.outputs.VERSION }} |
| 232 | +
|
| 233 | + cf-deploy: |
| 234 | + runs-on: ubuntu-20.04 |
| 235 | + if: startsWith(github.ref, 'refs/tags/') |
| 236 | + needs: package-build |
| 237 | + steps: |
| 238 | + - uses: actions/checkout@v2 |
| 239 | + - name: Download package from draft release |
| 240 | + run: ./download-draft-package.sh |
| 241 | + env: |
| 242 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 243 | + - name: Install CF CLI |
| 244 | + run: | |
| 245 | + sudo apt-get update |
| 246 | + sudo apt-get install -y wget gnupg gnupg2 gnupg1 |
| 247 | + wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - |
| 248 | + echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list |
| 249 | + sudo apt-get update |
| 250 | + sudo apt-get install cf-cli |
| 251 | + - name: Log in to Cloud Foundry |
| 252 | + run: cf login -a $CF_ENDPOINT -u $CF_USERNAME -p $CF_PASSWORD |
| 253 | + env: |
| 254 | + CF_ENDPOINT: ${{ secrets.CF_ENDPOINT }} |
| 255 | + CF_PASSWORD: ${{ secrets.CF_PASSWORD }} |
| 256 | + CF_USERNAME: ${{ secrets.CF_USERNAME }} |
| 257 | + - run: ./test-package.sh --skip-package --skip-heroku |
| 258 | + |
| 259 | + heroku-deploy: |
| 260 | + runs-on: ubuntu-20.04 |
| 261 | + if: startsWith(github.ref, 'refs/tags/') |
| 262 | + needs: package-build |
| 263 | + steps: |
| 264 | + - uses: actions/checkout@v2 |
| 265 | + - run: ./download-draft-package.sh |
| 266 | + env: |
| 267 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 268 | + - name: Install Heroku CLI |
| 269 | + run: curl https://cli-assets.heroku.com/install-ubuntu.sh | sh |
| 270 | + - name: Provide Heroku credentials |
| 271 | + run: "echo $HEROKU_NETRC >> $HOME/.netrc" |
| 272 | + env: |
| 273 | + HEROKU_NETRC: ${{ secrets.HEROKU_NETRC }} |
| 274 | + - name: Configure git |
| 275 | + run: | |
| 276 | + git config --global init.defaultBranch main |
| 277 | + git config --global user.email "[email protected]" |
| 278 | + git config --global user.name "Postfacto Robot" |
| 279 | + - run: ./test-package.sh --skip-package --skip-cf |
| 280 | + |
| 281 | + docker-smoke: |
| 282 | + runs-on: ubuntu-20.04 |
| 283 | + if: startsWith(github.ref, 'refs/tags/') |
| 284 | + needs: |
| 285 | + - docker-build |
| 286 | + - smoke-build |
| 287 | + steps: |
| 288 | + - uses: actions/checkout@v2 |
| 289 | + - uses: docker/setup-buildx-action@v1 |
| 290 | + - name: Get full tag |
| 291 | + id: full_tag |
| 292 | + run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} |
| 293 | + - name: Smoke test Docker containers |
| 294 | + run: | |
| 295 | + docker-compose run setup |
| 296 | + docker-compose run test |
| 297 | + working-directory: docker/smoke/ |
| 298 | + env: |
| 299 | + |
| 300 | + ADMIN_PASSWORD: 'opensesame' |
| 301 | + POSTGRES_PASSWORD: 'friend' |
| 302 | + SECRET_KEY_BASE: 'supersecret' |
| 303 | + TAG: ${{ steps.full_tag.outputs.VERSION }} |
0 commit comments