moved env variables to encrypted .env.ci file and fixed remaining issues with tests #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 && cd frontend && npm install | |
- run: npm run eslint && cd frontend && npm run eslint | |
- run: npm run build | |
- run: curl -sfS https://dotenvx.sh/install.sh | sh | |
- name: backend tests | |
run: dotenvx run -- npm run test | |
env: | |
DOTENV_PRIVATE_KEY_CI: ${{ secrets.DOTENV_PRIVATE_KEY_CI }} | |
- name: frontend tests | |
run: cd frontend && npm run test | |
- name: e2e tests | |
uses: cypress-io/github-action@v5 | |
with: | |
command: cd frontend && npm run cypress | |
start: npm run start:test | |
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 |