diff --git a/.github/workflows/health-checks.yml b/.github/workflows/health-checks.yml new file mode 100644 index 0000000..5e4048d --- /dev/null +++ b/.github/workflows/health-checks.yml @@ -0,0 +1,29 @@ +name: Health checks + +on: + schedule: + - cron: "0 * * * *" + +jobs: + health-checks: + runs-on: ubuntu-latest + steps: + - name: Check the deployed service URL + uses: jtalk/url-health-check-action@v4 + with: + # Check the following URLs one by one sequentially + url: https://fullstackopen-part11-3cp8.onrender.com + # Follow redirects, or just report success on 3xx status codes + follow-redirect: false # Optional, defaults to "false" + # Fail this action after this many failed attempts + max-attempts: 3 # Optional, defaults to 1 + # Delay between retries + retry-delay: 5s # Optional, only applicable to max-attempts > 1 + # Retry all errors, including 404. This option might trigger curl upgrade. + retry-all: false # Optional, defaults to "false" + # String representation of cookie attached to health check request. + # Format: `Name=Value` + # cookie: "token=asdf1234" # Optional, default is empty + # Basic auth login password pair. + # Format: `login:password` + # basic-auth: "login:password" # Optional, default is empty \ No newline at end of file diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml new file mode 100644 index 0000000..8189296 --- /dev/null +++ b/.github/workflows/pipeline.yml @@ -0,0 +1,71 @@ +name: Deployment pipeline + +on: + push: + branches: + - main + pull_request: + branches: [main] + types: [opened, synchronize] + +jobs: + simple_deployment_pipeline: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install and lint backend + run: | + npm install + npm run lint + working-directory: phonebook-backend + + - name: Install, lint and build frontend + run: | + npm install + npm run lint + npm run build + working-directory: phonebook-frontend + + - name: Notify success + uses: rjstone/discord-webhook-notify@v2 + if: success() + with: + webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} + severity: info + details: A new version has been released + title: ${{ github.repository }} + description: ${{ github.event.head_commit.author.username }} - https://github.com/${{ github.repository }}/commit/${{ github.sha }} + + - name: Notify failure + uses: rjstone/discord-webhook-notify@v2 + if: failure() + with: + webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} + severity: error + details: Build failed + title: ${{ github.repository }} + description: ${{ github.event.head_commit.author.username }} - https://github.com/${{ github.repository }}/commit/${{ github.sha }} + + - name: Deploy app + uses: sws2apps/render-deployment@v1.8.0 + if: github.event_name == 'push' && !contains(github.event.head_commit.message, '#skip') + with: + serviceId: ${{ secrets.RENDER_SERVICE_ID }} + apiKey: ${{ secrets.RENDER_API_KEY }} + multipleDeployment: false + + tag_release: + needs: [simple_deployment_pipeline] + runs-on: ubuntu-latest + if: | + github.event_name == 'push' && !contains(github.event.head_commit.message, '#skip') + steps: + - uses: actions/checkout@v4 + - name: Bump version and push tag + uses: anothrNick/github-tag-action@1.73.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..981eb65 --- /dev/null +++ b/README.MD @@ -0,0 +1 @@ +https://fullstackopen-part11-3cp8.onrender.com/ \ No newline at end of file