Skip to content

Commit

Permalink
chore: improved ci/cd (#109)
Browse files Browse the repository at this point in the history
Closes #108
Redo #76
  • Loading branch information
BeroBurny authored Jan 13, 2025
1 parent ddc7608 commit 2d61810
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 15 deletions.
34 changes: 30 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,37 @@ jobs:

- name: Publish Docs to Cloudflare Pages
if: ${{ steps.release.outputs.releases_created }}
uses: cloudflare/pages-action@v1
uses: cloudflare/wrangler-action@v3
with:
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 2238a825c5aca59233eab1f221f7aefb
command: pages deploy ./docs/build --project-name=sprinter-docs

- name: Publish POC to Cloudflare Pages
if: ${{ steps.release.outputs.releases_created }}
uses: cloudflare/wrangler-action@v3
with:
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 2238a825c5aca59233eab1f221f7aefb
command: pages deploy ./web/.svelte-kit/cloudflare --project-name=sprinter-poc

# old deployment
- name: Publish Docs to Cloudflare Pages (old project)
if: ${{ steps.release.outputs.releases_created }}
uses: cloudflare/wrangler-action@v3
with:
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 2238a825c5aca59233eab1f221f7aefb
projectName: gopher-docs
directory: ./docs/build
command: pages deploy ./docs/build --project-name=gopher-docs

- name: Publish POC to Cloudflare Pages (old project)
if: ${{ steps.release.outputs.releases_created }}
uses: cloudflare/wrangler-action@v3
with:
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref || github.ref_name }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 2238a825c5aca59233eab1f221f7aefb
command: pages deploy ./web/.svelte-kit/cloudflare --project-name=gopher-poc
64 changes: 54 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,65 @@ jobs:
run: 'yarn run test:unit'
- name: "Integrations Tests"
run: 'yarn run test:integrations'
- name: Publish POC to Cloudflare Pages
uses: cloudflare/pages-action@v1
- name: Set branch name for Cloudflare Pages
id: cf-branch
run: |
if [[ "${{ github.ref_name }}" == "master" ]]; then
echo "CF_BRANCH_NAME=preview" >> $GITHUB_ENV
else
echo "CF_BRANCH_NAME=${{ github.head_ref || github.ref_name }}" >> $GITHUB_ENV
fi
- name: Publish Docs to Cloudflare Pages
id: docs-publish
uses: cloudflare/wrangler-action@v3
with:
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 2238a825c5aca59233eab1f221f7aefb
projectName: gopher-poc
directory: ./web/.svelte-kit/cloudflare
command: pages deploy ./docs/build --project-name=sprinter-docs --branch=${{ env.CF_BRANCH_NAME }}
- name: Publish POC to Cloudflare Pages
id: poc-publish
uses: cloudflare/wrangler-action@v3
with:
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref || github.ref_name }}
- name: Publish Preview Docs to Cloudflare Pages
uses: cloudflare/pages-action@v1
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 2238a825c5aca59233eab1f221f7aefb
command: pages deploy ./web/.svelte-kit/cloudflare --project-name=sprinter-poc --branch=${{ env.CF_BRANCH_NAME }}
- name: Generate Deployment Summary
run: |
echo "# 🚀 Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| **Project** | **Preview URL** |" >> $GITHUB_STEP_SUMMARY
echo "| ----------------------- | ---------------- |" >> $GITHUB_STEP_SUMMARY
echo "| **Docs** | [View Docs -> ${{ steps.docs-publish.outputs.deployment-url }}](${{ steps.docs-publish.outputs.deployment-url }}) |" >> $GITHUB_STEP_SUMMARY
echo "| **POC** | [View POC -> ${{ steps.poc-publish.outputs.deployment-url }}](${{ steps.poc-publish.outputs.deployment-url }}) |" >> $GITHUB_STEP_SUMMARY
- name: Notify About Deployment
if: ${{ github.actor != 'dependabot[bot]' }}
uses: actions/github-script@v7
with:
script: |
const docsUrl = `**Docs:** [View Deployment -> ${{ steps.docs-publish.outputs.deployment-url }}](${{ steps.docs-publish.outputs.deployment-url }})`;
const pocUrl = `**POC:** [View Deployment -> ${{ steps.poc-publish.outputs.deployment-url }}](${{ steps.poc-publish.outputs.deployment-url }})`;
const message = `🚀 **Deployment Completed**\n\n${docsUrl}\n${pocUrl}`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message,
});
# old deployment
- name: Publish Docs to Cloudflare Pages (old project)
uses: cloudflare/wrangler-action@v3
with:
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 2238a825c5aca59233eab1f221f7aefb
projectName: gopher-docs-preview
directory: ./docs/build
command: pages deploy ./docs/build --project-name=gopher-docs --branch=${{ env.CF_BRANCH_NAME }}
- name: Publish POC to Cloudflare Pages (old project)
uses: cloudflare/wrangler-action@v3
with:
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref || github.ref_name }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 2238a825c5aca59233eab1f221f7aefb
command: pages deploy ./web/.svelte-kit/cloudflare --project-name=gopher-poc --branch=${{ env.CF_BRANCH_NAME }}
55 changes: 55 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Deploy Docs
on:
workflow_dispatch:
inputs:
environment:
description: 'Select deployment environment'
required: true
default: 'preview'
type: choice
options:
- production
- preview

jobs:
manual-deploy-docs:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'

- run: corepack enable

- run: yarn install --immutable

- run: yarn build

- name: Set branch name for Cloudflare Pages
id: cf-branch
run: |
if [[ "${{ github.ref_name }}" == "production" ]]; then
echo "CF_BRANCH_NAME=master" >> $GITHUB_ENV
else
echo "CF_BRANCH_NAME=preview" >> $GITHUB_ENV
fi
- name: Publish Docs to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 2238a825c5aca59233eab1f221f7aefb
command: pages deploy ./docs/build --project-name=sprinter-docs --branch=${{ env.CF_BRANCH_NAME }}

- name: Publish Docs to Cloudflare Pages (old project)
uses: cloudflare/wrangler-action@v3
with:
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 2238a825c5aca59233eab1f221f7aefb
command: pages deploy ./docs/build --project-name=gopher-docs --branch=${{ env.CF_BRANCH_NAME }}
1 change: 1 addition & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"docs": "0.0.1",
"packages/sdk": "1.1.2",
"packages/react": "1.1.2"
}
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docs",
"version": "0.0.0",
"version": "0.0.1",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand Down
9 changes: 9 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"plugins": [],
"packages": {
"docs": {
"releaseType": "node",
"draft": false,
"prerelease": false,
"bumpMinorPreMajor": false,
"bumpPatchForMinorPreMajor": false,
"changelogPath": "CHANGELOG.md",
"versioning": "default"
},
"packages/sdk": {
"releaseType": "node",
"draft": false,
Expand Down

0 comments on commit 2d61810

Please sign in to comment.