From da4d78c8681892c63d5043a9e9d412dd66e34716 Mon Sep 17 00:00:00 2001 From: Veeti Laine Date: Thu, 11 Jul 2024 23:26:41 +0300 Subject: [PATCH] added deployment pipeline --- .github/workflows/pipeline.yml | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/pipeline.yml diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml new file mode 100644 index 0000000..5aab1b3 --- /dev/null +++ b/.github/workflows/pipeline.yml @@ -0,0 +1,63 @@ +name: Deployment pipeline + +on: + pull_request: + branches: + - main + types: [opened, synchronize] + push: + branches: + - main + +env: + COMMIT_MESSAGES: ${{ toJson(github.event.commits.*.message) }} + COMMIT: ${{ toJson(github.event.commits)[0] }} + +jobs: + simple_deployment_pipeline: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - run: npm install + - run: npm run eslint + - run: npm run build + - run: npm run test + - name: e2e tests + uses: cypress-io/github-action@v5 + with: + command: cd frontend && npm run cypress + start: npm run start + wait-on: http://localhost:5000 + - name: deployment + if: ${{ github.event_name == 'push' }} + run: curl https://api.render.com/deploy/srv-${{ secrets.RENDER_SERVICE_ID }}?key=${{ secrets.RENDER_API_KEY }} + - name: Success + uses: rjstone/discord-webhook-notify@v1 + if: ${{ github.event_name == 'push' && success() }} + with: + severity: info + text: A new version of Bloglist App deployed + details: 'to https://full-stack-open-pokedex-pupa.onrender.com/' + webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} + - name: Failure + uses: rjstone/discord-webhook-notify@v1 + if: ${{ github.event_name == 'push' && failure() }} + with: + severity: error + text: Build failed! + details: ${{ format('commit {0} by {1} broke the build :((', env.COMMIT.url, env.COMMIT.author.name) }} + webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} + tag_release: + needs: [simple_deployment_pipeline] + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + - name: Bump version and push tag + if: ${{ github.event_name == 'push' && !contains(join(env.COMMIT_MESSAGES, ', '), '#skip')}} + uses: anothrNick/github-tag-action@8c8163ef62cf9c4677c8e800f36270af27930f42 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DEFAULT_BUMP: patch \ No newline at end of file