-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #747 from whilefoo/reusable-deploy
Reusable deploy
- Loading branch information
Showing
2 changed files
with
13 additions
and
78 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,81 +7,15 @@ on: | |
- completed | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-22.04 | ||
deploy-to-cloudflare: | ||
name: Deploy to Cloudflare Pages | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/[email protected] | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18.14.1" | ||
|
||
- name: Wrangler Install | ||
run: npm install -g wrangler | ||
|
||
- name: "Download Artifact" | ||
uses: actions/[email protected] | ||
with: | ||
script: | | ||
const fs = require("fs"); | ||
const downloadArtifact = require('${{ github.workspace }}/utils/download-artifact.js'); | ||
const workflow_run_id = '${{ github.event.workflow_run.id }}'; | ||
const workspace = '${{ github.workspace }}'; | ||
downloadArtifact({github, context, fs, workflow_run_id, workspace}) | ||
- name: Extract Artifact | ||
run: unzip pr.zip && unzip pull-request.zip && ls | ||
|
||
- name: Deploy Cloudflare | ||
env: | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
REPOSITORY: ${{ github.repository }} | ||
PRODUCTION_BRANCH: "development" | ||
OUTPUT_DIRECTORY: "dist" | ||
run: | | ||
IFS='/' read -ra fields <<< "$REPOSITORY" | ||
projectName="${fields[1]}" | ||
echo $projectName | ||
wrangler pages project list > project_list.txt | ||
if grep -q $projectName project_list.txt; then | ||
echo "Project found" | ||
else | ||
echo "Project not found" | ||
wrangler pages project create "$projectName" --production-branch "$PRODUCTION_BRANCH" | ||
fi | ||
wrangler pages publish "$OUTPUT_DIRECTORY" --project-name "$projectName" > ./deployments.log | ||
ls -la | ||
cat deployments.log | ||
# - name: Deploy Railway | ||
# run: | | ||
# cd dist | ||
# npm i -g @railway/cli | ||
# RAILWAY_TOKEN=${{ secrets.RAILWAY_API_TOKEN }} railway link ${{ secrets.RAILWAY_PROJECT_ID }} | ||
# RAILWAY_TOKEN=${{ secrets.RAILWAY_API_TOKEN }} railway up | ||
|
||
- name: Get UbiquiBot Token | ||
uses: tibdex/[email protected] | ||
id: get_installation_token | ||
with: | ||
app_id: ${{ secrets.UBIQUITY_BOUNTY_BOT_APP_ID }} | ||
private_key: ${{ secrets.UBIQUITY_BOUNTY_BOT_PRIVATE_KEY }} | ||
|
||
- name: Save UbiquiBot Token | ||
env: | ||
TOKEN: ${{ steps.get_installation_token.outputs.token }} | ||
run: | | ||
echo "The generated token is masked: ${TOKEN}" | ||
- name: Deploy Comment as UbiquiBot | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ steps.get_installation_token.outputs.token }} | ||
script: | | ||
const fs = require("fs"); | ||
const printDeploymentsLog = require('${{ github.workspace }}/utils/print-deployments-logs.js'); | ||
await printDeploymentsLog({github, context, fs}); | ||
uses: ubiquity/.github/.github/workflows/deploy.yml@main | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
secrets: | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
UBIQUITY_BOUNTY_BOT_APP_ID: ${{ secrets.UBIQUITY_BOUNTY_BOT_APP_ID }} | ||
UBIQUITY_BOUNTY_BOT_PRIVATE_KEY: ${{ secrets.UBIQUITY_BOUNTY_BOT_PRIVATE_KEY }} |
611472a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.