From 0ef2ca9030d26cf83ddcb929c87db3682839aa31 Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Thu, 5 Dec 2024 13:40:09 +0000 Subject: [PATCH 01/13] =?UTF-8?q?chore:=20=F0=9F=A4=96=20site=20deploy=20C?= =?UTF-8?q?I/CD=20with=20CLI,=20include=20dashboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/setup-nodejs/action.yml | 17 +++ .github/workflows/fleek-deploy-common.yml | 112 ++++++++++++++++++ .github/workflows/fleek-deploy-production.yml | 14 +++ .github/workflows/fleek-deploy-staging.yml | 14 +++ scripts/download_artifact | 67 +++++++++++ scripts/prepare_dashboard_files | 26 ++++ scripts/setup-ci-dotenv | 31 +++++ scripts/setup-fleek-config | 35 ++++++ 8 files changed, 316 insertions(+) create mode 100644 .github/actions/setup-nodejs/action.yml create mode 100644 .github/workflows/fleek-deploy-common.yml create mode 100644 .github/workflows/fleek-deploy-production.yml create mode 100644 .github/workflows/fleek-deploy-staging.yml create mode 100755 scripts/download_artifact create mode 100755 scripts/prepare_dashboard_files create mode 100755 scripts/setup-ci-dotenv create mode 100755 scripts/setup-fleek-config diff --git a/.github/actions/setup-nodejs/action.yml b/.github/actions/setup-nodejs/action.yml new file mode 100644 index 000000000..2e377a5c8 --- /dev/null +++ b/.github/actions/setup-nodejs/action.yml @@ -0,0 +1,17 @@ +name: πŸ€– Setup Nodejs + +runs: + using: 'composite' + steps: + - uses: pnpm/action-setup@v3 + name: Install pnpm + id: pnpm-install + with: + version: 9 + run_install: false + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' diff --git a/.github/workflows/fleek-deploy-common.yml b/.github/workflows/fleek-deploy-common.yml new file mode 100644 index 000000000..42a886d18 --- /dev/null +++ b/.github/workflows/fleek-deploy-common.yml @@ -0,0 +1,112 @@ +name: ⚑️ Deploy site (Common) + +on: + workflow_dispatch: + workflow_call: + inputs: + environment: + required: true + type: string + +jobs: + deploy-to-fleek: + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + env: + FLEEK_TOKEN: ${{ secrets.FLEEK_TOKEN }} + FLEEK_PROJECT_ID: ${{ secrets.FLEEK_PROJECT_ID }} + FLEEK_SLUG: ${{ secrets.FLEEK_SLUG }} + DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - uses: ./.github/actions/setup-nodejs + + - name: Install Doppler CLI + uses: dopplerhq/cli-action@v3 + + - name: Setup Doppler + run: | + doppler configure set token ${{ secrets.DOPPLER_TOKEN }} + doppler configure set project ${{ secrets.DOPPLER_PROJECT }} + doppler configure set config ${{ secrets.DOPPLER_CONFIG }} + + - name: Env vars health check + run: | + if ! doppler run -- printenv | grep -q 'NEXT_PUBLIC_SDK__AUTHENTICATION_URL'; then + echo "πŸ‘Ή Oops! Missing required environment variable during health check..." + exit 1 + fi + + echo "πŸš‘ Doppler envVars seem healthy!" + + - name: Setup dotenv + run: | + scripts/setup-ci-dotenv + + - name: Install Fleek CLI + run: npm i -g @fleek-platform/cli + + - name: Install Packages + run: npm install + + - name: Setup fleek.config.json + run: | + DIST="out" + BUILD="pnpm run build" + + .scripts/setup-fleek-config \ + "$FLEEK_SLUG" \ + "$DIST" \ + "$BUILD" + + - name: Build & deploy + run: | + fleek sites deploy + + # The build output can be downloaded + # by external processes, e.g. website + # Obs: The output contains a set of hard-typed + # values computed from envVars. For example, + # the application base URL. + # - name: Store build output + # uses: actions/upload-artifact@v4 + # with: + # name: build-output-${{ env.FLEEK_SLUG }} + # path: out + # retention-days: 90 + + - name: Download Dashboard artifact + id: download_dashboard_artifact + run: | + github_token="$GITHUB_TOKEN" + source_repo="fleek-platform/dashboard" + dashboard_build_output_filename="build-output-fleek-dashboard-staging" + latest_artifact_file="$dashboard_build_output_filename.zip" + + .scripts/download_artifact \ + "$github_token" \ + "$source_repo" \ + "$dashboard_build_output_filename" \ + "$latest_artifact_file" + + echo "latest_dashboard_artifact=$latest_artifact_file" >> "$GITHUB_OUTPUT" + + - name: Prepare Dashboard files + env: + ARTIFACT: ${{ steps.download_dashboard_artifact.outputs.latest_dashboard_artifact }} + OUTPUT_PATH: "dist" + run: | + if ! scripts/prepare_dashboard_files "$ARTIFACT" "$OUTPUT_PATH"; then + echo "πŸ‘Ή Oops! Failed to prepare the dashboard files for some reason..." + exit 1 + fi + + - name: Clear + run: | + rm .env diff --git a/.github/workflows/fleek-deploy-production.yml b/.github/workflows/fleek-deploy-production.yml new file mode 100644 index 000000000..230181005 --- /dev/null +++ b/.github/workflows/fleek-deploy-production.yml @@ -0,0 +1,14 @@ +name: ⚑️ Deploy Dashboard (Production) + +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + deploy-to-staging: + uses: ./.github/workflows/fleek-deploy-common.yml + with: + environment: production + secrets: inherit diff --git a/.github/workflows/fleek-deploy-staging.yml b/.github/workflows/fleek-deploy-staging.yml new file mode 100644 index 000000000..49091fb96 --- /dev/null +++ b/.github/workflows/fleek-deploy-staging.yml @@ -0,0 +1,14 @@ +name: ⚑️ Deploy Dashboard (Staging) + +on: + workflow_dispatch: + push: + branches: + - develop + +jobs: + deploy-to-staging: + uses: ./.github/workflows/fleek-deploy-common.yml + with: + environment: staging + secrets: inherit diff --git a/scripts/download_artifact b/scripts/download_artifact new file mode 100755 index 000000000..6f6ba786f --- /dev/null +++ b/scripts/download_artifact @@ -0,0 +1,67 @@ +#!/bin/bash + +ghToken="$1" +orgRepo="$2" +targetArtifactFilename="$3" +outputFilename="$4" + +if [[ -z "$1" || -z "$2" || -z "$3" || -z "$4" ]]; then + echo "πŸ‘Ή Oops! Missing arguments, e.g. github token, organisation repository, artifact name, etc" + exit 1 +fi + +result=$(curl -sL \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $ghToken" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/$orgRepo/actions/artifacts") + +if [[ -z "$result" ]]; then + echo "πŸ‘Ή Oops! The request for artifacts API has an unexpected response $result" + exit 1 +fi + +countMatchingFilename=$(echo "$result" | jq "[.artifacts[] | select(.name == \"$targetArtifactFilename\")] | length") + +if [[ "$countMatchingFilename" -eq 0 ]]; then + echo "πŸ‘Ή Oops! Didn't find any artifacts of name $targetArtifactFilename" + exit 1 +fi + +echo "βœ… Found $countMatchingFilename artifact matches for name $targetArtifactFilename" + +filteredByFilename=$(echo "$result" | jq "[.artifacts[] | select(.name == \"$targetArtifactFilename\")]") + +if [[ -z "$filteredByFilename" ]]; then + echo "πŸ‘Ή Oops! Failed to get the latest artifact from response $result" + exit 1 +fi + +latestArtifact=$(echo "$filteredByFilename" | jq 'sort_by(.created_at) | reverse | .[0]') + +if [[ -z "$latestArtifact" ]]; then + echo "πŸ‘Ή Oops! Failed to get the latest artifact from response $result" + exit 1 +fi + +latestArtifactId=$(echo "$latestArtifact" | jq '.id') +latestArtifactName=$(echo "$latestArtifact" | jq '.name') + +if [[ -z "$latestArtifactId" ]]; then + echo "πŸ‘Ή Oops! Failed to get the latest artifact id from response $latestArtifact" + exit 1 +fi + +echo "βœ… Got artifact id $latestArtifactId of name $latestArtifactName" + +if ! curl -sL \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $ghToken" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/$orgRepo/actions/artifacts/$latestArtifactId/zip" \ + --output "$outputFilename"; then + echo "πŸ‘Ή Oops! Failed download the artifact id $latestArtifactId" + exit 1 +fi + +echo "βœ… Downloaded artifact $outputFilename" diff --git a/scripts/prepare_dashboard_files b/scripts/prepare_dashboard_files new file mode 100755 index 000000000..8755e06f3 --- /dev/null +++ b/scripts/prepare_dashboard_files @@ -0,0 +1,26 @@ +#!/bin/bash + +if [[ -z "$1" || -z "$2" ]]; then + echo "πŸ‘Ή Oops! Missing arguments. Have you provided a filename and output path?" + exit 1 +fi + +artifact_filename="$1" +output_path="$2" + +if ! unzip -o "$artifact_filename"; then + echo "πŸ‘Ή Oops! Failed to unzip $artifact_filename" + exit 1 +fi + +echo "βœ… Unziped $artifact_filename" + +if ! rm "$artifact_filename"; then + echo "πŸ‘Ή Oops! Failed to delete $artifact_filename" + exit 1 +fi + +echo "βœ… Deleted $artifact_filename" + +echo "πŸ€– The file content generated the following file tree..." +tree -L 3 -I "$output_path" diff --git a/scripts/setup-ci-dotenv b/scripts/setup-ci-dotenv new file mode 100755 index 000000000..086609c47 --- /dev/null +++ b/scripts/setup-ci-dotenv @@ -0,0 +1,31 @@ +#!/bin/bash + +targetEnvPath=".env" +# Using dotenv due to `fleek sites deploy` +# failing to authenticate via the host or declared +# fleek env vars for some reason +doppler secrets download \ + --no-file \ + --format env > "$targetEnvPath" + +# The Fleek CLI supports envVars overrides +# for this reason, we should exclude some vars +# originated from doppler +EXCLUDE_CSV=( "UI__APP_URL" "SDK__GRAPHQL_API_URL" "SDK__AUTH_APPS_URL" "SDK__IPFS__STORAGE_API_URL" "SDK__UPLOAD_PROXY_API_URL" "SITE_SLUG_DOMAIN" ) + +for item in "${EXCLUDE_CSV[@]}"; do + if [[ "$OSTYPE" == "darwin"* ]]; then + sed -i '' "/^${item}=/d" "$targetEnvPath" + else + sed -i "/^${item}=/d" "$targetEnvPath" + fi +done + +for item in "${EXCLUDE_CSV[@]}"; do + if grep -q "^${item}=" "$targetEnvPath"; then + echo "πŸ‘Ή Oops! Failed to exclude $item from $targetEnvPath" + exit 1 + fi +done + +echo "βœ… Completed dot env setup!" diff --git a/scripts/setup-fleek-config b/scripts/setup-fleek-config new file mode 100755 index 000000000..79effb818 --- /dev/null +++ b/scripts/setup-fleek-config @@ -0,0 +1,35 @@ +#!/bin/bash + + +if [[ -z "$1" || -z "$2" || -z "$3" ]]; then + echo "πŸ‘Ή Oops! Missing arguments required for slug, distDir and buildCommand." + exit 1 +fi + +fleekConfigPath="./fleek.config.json" +temp="$fleekConfigPath.tmp" + +if ! jq --arg slug "$1" --arg distDir "$2" --arg buildCommand "$3" ' + .sites[0].slug = $slug | + .sites[0].distDir = $distDir | + .sites[0].buildCommand = $buildCommand +' "$fleekConfigPath" > "$temp"; then + echo "πŸ‘Ή Oops! Failed to set $fleekConfigPath for some reason..." + exit 1 +fi + +if ! mv "$fleekConfigPath.tmp" "$fleekConfigPath"; then + echo "πŸ‘Ή Oops! Failed to override the $fleekConfigPath" + exit 1 +fi + +if ! rm "$temp"; then + echo "⚠️ WARNING: Failed to remove $temp file" +fi + +echo "πŸ” The $fleekConfigPath content is:" +cat "$fleekConfigPath" +echo + +echo "βœ… Completed fleek config setup!" + From fd3bdd55243c0a6f2792b0018947e42d4e02e592 Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Fri, 3 Jan 2025 09:33:20 +0000 Subject: [PATCH 02/13] =?UTF-8?q?chore:=20=F0=9F=A4=96=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/prepare_dashboard_files | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/prepare_dashboard_files b/scripts/prepare_dashboard_files index 8755e06f3..4226053a5 100755 --- a/scripts/prepare_dashboard_files +++ b/scripts/prepare_dashboard_files @@ -8,7 +8,7 @@ fi artifact_filename="$1" output_path="$2" -if ! unzip -o "$artifact_filename"; then +if ! unzip -q -o "$artifact_filename" -d "$output_path"; then echo "πŸ‘Ή Oops! Failed to unzip $artifact_filename" exit 1 fi @@ -22,5 +22,10 @@ fi echo "βœ… Deleted $artifact_filename" +if ! mkdir -p "$output_path"; then + echo "πŸ‘Ή Oops! Failed to create the output path $output_path" + exit 1 +fi + echo "πŸ€– The file content generated the following file tree..." -tree -L 3 -I "$output_path" +tree -L 2 "$output_path" From a8676ec165212de7c8e80eb82a84bfb10ec225ef Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Fri, 3 Jan 2025 18:24:13 +0000 Subject: [PATCH 03/13] =?UTF-8?q?chore:=20=F0=9F=A4=96=20introduce=20repla?= =?UTF-8?q?ce=20dashboard=20paths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/fleek-deploy-common.yml | 49 ++++++++----------- scripts/replace_dashboard_paths | 38 ++++++++++++++ scripts/setup-fleek-config | 4 +- ...hboard_files => unarchive_dashboard_files} | 0 4 files changed, 60 insertions(+), 31 deletions(-) create mode 100755 scripts/replace_dashboard_paths rename scripts/{prepare_dashboard_files => unarchive_dashboard_files} (100%) diff --git a/.github/workflows/fleek-deploy-common.yml b/.github/workflows/fleek-deploy-common.yml index 42a886d18..3ed89b9f1 100644 --- a/.github/workflows/fleek-deploy-common.yml +++ b/.github/workflows/fleek-deploy-common.yml @@ -55,32 +55,6 @@ jobs: - name: Install Packages run: npm install - - name: Setup fleek.config.json - run: | - DIST="out" - BUILD="pnpm run build" - - .scripts/setup-fleek-config \ - "$FLEEK_SLUG" \ - "$DIST" \ - "$BUILD" - - - name: Build & deploy - run: | - fleek sites deploy - - # The build output can be downloaded - # by external processes, e.g. website - # Obs: The output contains a set of hard-typed - # values computed from envVars. For example, - # the application base URL. - # - name: Store build output - # uses: actions/upload-artifact@v4 - # with: - # name: build-output-${{ env.FLEEK_SLUG }} - # path: out - # retention-days: 90 - - name: Download Dashboard artifact id: download_dashboard_artifact run: | @@ -102,11 +76,30 @@ jobs: ARTIFACT: ${{ steps.download_dashboard_artifact.outputs.latest_dashboard_artifact }} OUTPUT_PATH: "dist" run: | - if ! scripts/prepare_dashboard_files "$ARTIFACT" "$OUTPUT_PATH"; then - echo "πŸ‘Ή Oops! Failed to prepare the dashboard files for some reason..." + if ! scripts/unarchive_dashboard_files "$ARTIFACT" "$OUTPUT_PATH"; then + echo "πŸ‘Ή Oops! Failed to unarchive the dashboard files for some reason..." + exit 1 + fi + + if ! scripts/replace_dashboard_paths "$OUTPUT_PATH" /dashboard; then + echo "πŸ‘Ή Oops! Failed to replace the dashboard paths for some reason..." exit 1 fi + - name: Setup fleek.config.json + run: | + DIST="out" + BUILD="pnpm run build" + + ./scripts/setup-fleek-config \ + "$FLEEK_SLUG" \ + "$DIST" \ + "$BUILD" + + - name: Build & deploy + run: | + fleek sites deploy + - name: Clear run: | rm .env diff --git a/scripts/replace_dashboard_paths b/scripts/replace_dashboard_paths new file mode 100755 index 000000000..865991e54 --- /dev/null +++ b/scripts/replace_dashboard_paths @@ -0,0 +1,38 @@ +#!/bin/bash + +if [[ -z "$1" || -z "$2" ]]; then + echo "πŸ‘Ή Oops! Missing arguments. Have you provided the output path and a base path for the URL?" + exit 1 +fi + +output_path="$1" +base_path="$2" +target="$output_path/$base_path/**/*.html" + +next_static="_next/static" + +# Media path +next_static_media_path_from="$next_static/media" +next_static_media_path_to="$base_path/$next_static/media" + +# Chunks path +next_static_chunks_path_from="$next_static/chunks" +next_static_chunks_path_to="$base_path/$next_static/chunks" + +find "dist/$base_path" -name "*.html" -type f | while read -r target; do + if ! sed -i "s|$next_static_media_path_from|$next_static_media_path_to|g" "$target"; then + echo "πŸ‘Ή Oops! Failed to replace $next_static_media_path_from to $nexT_static_media_path_to for some reason..." + exit 1 + fi +done + +echo "βœ… Prefixed $next_static_media_path_from" + +find "dist/$base_path" -name "*.html" -type f | while read -r target; do + if ! sed -i "s|$next_static_chunks_path_from|$next_static_chunks_path_to|g" "$target"; then + echo "πŸ‘Ή Oops! Failed to replace $next_static_chunks_path_from to $next_static_chunks_path_to for some reason..." + exit 1 + fi +done + +echo "βœ… Prefixed $next_static_chunks_path_from" diff --git a/scripts/setup-fleek-config b/scripts/setup-fleek-config index 79effb818..36be70925 100755 --- a/scripts/setup-fleek-config +++ b/scripts/setup-fleek-config @@ -1,6 +1,5 @@ #!/bin/bash - if [[ -z "$1" || -z "$2" || -z "$3" ]]; then echo "πŸ‘Ή Oops! Missing arguments required for slug, distDir and buildCommand." exit 1 @@ -18,7 +17,7 @@ if ! jq --arg slug "$1" --arg distDir "$2" --arg buildCommand "$3" ' exit 1 fi -if ! mv "$fleekConfigPath.tmp" "$fleekConfigPath"; then +if ! mv "$temp" "$fleekConfigPath"; then echo "πŸ‘Ή Oops! Failed to override the $fleekConfigPath" exit 1 fi @@ -32,4 +31,3 @@ cat "$fleekConfigPath" echo echo "βœ… Completed fleek config setup!" - diff --git a/scripts/prepare_dashboard_files b/scripts/unarchive_dashboard_files similarity index 100% rename from scripts/prepare_dashboard_files rename to scripts/unarchive_dashboard_files From ed1df02e070ed29c7db9012db5fc4531e65b4986 Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Thu, 9 Jan 2025 18:32:30 +0000 Subject: [PATCH 04/13] =?UTF-8?q?chore:=20=F0=9F=A4=96=20remove=20replace?= =?UTF-8?q?=20dashboard=20paths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/fleek-deploy-common.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/fleek-deploy-common.yml b/.github/workflows/fleek-deploy-common.yml index 3ed89b9f1..d05e58b81 100644 --- a/.github/workflows/fleek-deploy-common.yml +++ b/.github/workflows/fleek-deploy-common.yml @@ -80,11 +80,6 @@ jobs: echo "πŸ‘Ή Oops! Failed to unarchive the dashboard files for some reason..." exit 1 fi - - if ! scripts/replace_dashboard_paths "$OUTPUT_PATH" /dashboard; then - echo "πŸ‘Ή Oops! Failed to replace the dashboard paths for some reason..." - exit 1 - fi - name: Setup fleek.config.json run: | From 0e90406fb840ce7d0277518e1a58cb389c0bc5bc Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Thu, 27 Feb 2025 16:47:39 +0000 Subject: [PATCH 05/13] =?UTF-8?q?chore:=20=F0=9F=A4=96=20delete?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/replace_dashboard_paths | 38 --------------------------------- 1 file changed, 38 deletions(-) delete mode 100755 scripts/replace_dashboard_paths diff --git a/scripts/replace_dashboard_paths b/scripts/replace_dashboard_paths deleted file mode 100755 index 865991e54..000000000 --- a/scripts/replace_dashboard_paths +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -if [[ -z "$1" || -z "$2" ]]; then - echo "πŸ‘Ή Oops! Missing arguments. Have you provided the output path and a base path for the URL?" - exit 1 -fi - -output_path="$1" -base_path="$2" -target="$output_path/$base_path/**/*.html" - -next_static="_next/static" - -# Media path -next_static_media_path_from="$next_static/media" -next_static_media_path_to="$base_path/$next_static/media" - -# Chunks path -next_static_chunks_path_from="$next_static/chunks" -next_static_chunks_path_to="$base_path/$next_static/chunks" - -find "dist/$base_path" -name "*.html" -type f | while read -r target; do - if ! sed -i "s|$next_static_media_path_from|$next_static_media_path_to|g" "$target"; then - echo "πŸ‘Ή Oops! Failed to replace $next_static_media_path_from to $nexT_static_media_path_to for some reason..." - exit 1 - fi -done - -echo "βœ… Prefixed $next_static_media_path_from" - -find "dist/$base_path" -name "*.html" -type f | while read -r target; do - if ! sed -i "s|$next_static_chunks_path_from|$next_static_chunks_path_to|g" "$target"; then - echo "πŸ‘Ή Oops! Failed to replace $next_static_chunks_path_from to $next_static_chunks_path_to for some reason..." - exit 1 - fi -done - -echo "βœ… Prefixed $next_static_chunks_path_from" From 1d5e6ad8030ec255107c80076185369111604742 Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Thu, 27 Feb 2025 20:02:05 +0000 Subject: [PATCH 06/13] =?UTF-8?q?chore:=20=F0=9F=A4=96=20unarchive=20to=20?= =?UTF-8?q?temp=20dashboard=20path;=20post-build=20copy=20dashboard=20dir?= =?UTF-8?q?=20to=20dist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/fleek-deploy-common.yml | 12 ++++++++++-- README.md | 6 ++++++ package.json | 3 ++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fleek-deploy-common.yml b/.github/workflows/fleek-deploy-common.yml index d05e58b81..31bf0bf12 100644 --- a/.github/workflows/fleek-deploy-common.yml +++ b/.github/workflows/fleek-deploy-common.yml @@ -17,6 +17,7 @@ jobs: FLEEK_PROJECT_ID: ${{ secrets.FLEEK_PROJECT_ID }} FLEEK_SLUG: ${{ secrets.FLEEK_SLUG }} DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }} + DASHBOARD_UNARCHIVED_PATH: "temp/dashboard" steps: - name: Checkout uses: actions/checkout@v4 @@ -52,6 +53,10 @@ jobs: - name: Install Fleek CLI run: npm i -g @fleek-platform/cli + # TODO: Maybe separate into three steps: + # - Site build + # - Dashboard + # - Deploy - name: Install Packages run: npm install @@ -74,17 +79,20 @@ jobs: - name: Prepare Dashboard files env: ARTIFACT: ${{ steps.download_dashboard_artifact.outputs.latest_dashboard_artifact }} - OUTPUT_PATH: "dist" + OUTPUT_PATH: ${{ env.DASHBOARD_UNARCHIVED_PATH }} run: | if ! scripts/unarchive_dashboard_files "$ARTIFACT" "$OUTPUT_PATH"; then echo "πŸ‘Ή Oops! Failed to unarchive the dashboard files for some reason..." exit 1 fi + + echo "βœ… Unarchived the archive file $ARTIFACT, to $OUTPUT_PATH. It's contents are listed below:" + ls -la "$OUTPUT_PATH" - name: Setup fleek.config.json run: | DIST="out" - BUILD="pnpm run build" + BUILD="npm run build:ci && cp ${{ env.DASHBOARD_UNARCHIVED_PATH }} $DIST" ./scripts/setup-fleek-config \ "$FLEEK_SLUG" \ diff --git a/README.md b/README.md index 8d25b8555..e45716d76 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,12 @@ npm run build Tweak environment settings (src/settings.json), such as the site URL. Declare the `NODE_ENV` with value `prod` or `production` to switch environment target settings. +Alternatively, you can skip build checkups and build assets only: + +``` +npm run build:static_assets +``` + ## πŸ™ˆ Preview locally You can preview the distribution build locally by starting the preview HTTP server: diff --git a/package.json b/package.json index eb893b167..f92534ca5 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "scripts": { "dev": "astro dev", "start": "astro dev", - "build": "rm -rf dist && npm run check:strict && npm run check:json && astro build && ./scripts/build/copy-video-content-src-to-dist", + "build": "rm -rf dist && npm run check:strict && npm run check:json && npm run build:static_assets", + "build:static_assets": "astro build && ./scripts/build/copy-video-content-src-to-dist", "preview": "astro preview", "astro": "astro", "clean": "rm -rf .astro node_modules/.vite", From 21a8db26ca22e71c28fcf6c6814512967a099057 Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Thu, 27 Feb 2025 20:05:10 +0000 Subject: [PATCH 07/13] =?UTF-8?q?chore:=20=F0=9F=A4=96=20use=20npm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/setup-nodejs/action.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/actions/setup-nodejs/action.yml b/.github/actions/setup-nodejs/action.yml index 2e377a5c8..452b2b557 100644 --- a/.github/actions/setup-nodejs/action.yml +++ b/.github/actions/setup-nodejs/action.yml @@ -3,15 +3,8 @@ name: πŸ€– Setup Nodejs runs: using: 'composite' steps: - - uses: pnpm/action-setup@v3 - name: Install pnpm - id: pnpm-install - with: - version: 9 - run_install: false - - name: Setup node uses: actions/setup-node@v4 with: node-version: 20 - cache: 'pnpm' + cache: 'npm' From 1a4e533bd2e8e83ce8617721de258d377fa3f890 Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Thu, 27 Feb 2025 20:17:34 +0000 Subject: [PATCH 08/13] =?UTF-8?q?chore:=20=F0=9F=A4=96=20amend=20path=20en?= =?UTF-8?q?v?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/fleek-deploy-common.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fleek-deploy-common.yml b/.github/workflows/fleek-deploy-common.yml index 31bf0bf12..28098b69a 100644 --- a/.github/workflows/fleek-deploy-common.yml +++ b/.github/workflows/fleek-deploy-common.yml @@ -92,7 +92,7 @@ jobs: - name: Setup fleek.config.json run: | DIST="out" - BUILD="npm run build:ci && cp ${{ env.DASHBOARD_UNARCHIVED_PATH }} $DIST" + BUILD="npm run build:ci && cp -r $DASHBOARD_UNARCHIVED_PATH $DIST" ./scripts/setup-fleek-config \ "$FLEEK_SLUG" \ From 3e467eed8a598033193deedfbbe1933996244db2 Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Thu, 27 Feb 2025 20:22:44 +0000 Subject: [PATCH 09/13] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20use=20github?= =?UTF-8?q?=20repo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/fleek-deploy-production.yml | 3 +++ .github/workflows/fleek-deploy-staging.yml | 3 +++ .github/workflows/release-by-develop-hash.yml | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/fleek-deploy-production.yml b/.github/workflows/fleek-deploy-production.yml index 230181005..b3ed7cb30 100644 --- a/.github/workflows/fleek-deploy-production.yml +++ b/.github/workflows/fleek-deploy-production.yml @@ -5,6 +5,9 @@ on: push: branches: - main + # The workflow's dispatched on Release by develop hash + repository_dispatch: + types: [Release] jobs: deploy-to-staging: diff --git a/.github/workflows/fleek-deploy-staging.yml b/.github/workflows/fleek-deploy-staging.yml index 49091fb96..d30fa115a 100644 --- a/.github/workflows/fleek-deploy-staging.yml +++ b/.github/workflows/fleek-deploy-staging.yml @@ -5,6 +5,9 @@ on: push: branches: - develop + # The workflow's dispatched on Release by develop hash + repository_dispatch: + types: [Release] jobs: deploy-to-staging: diff --git a/.github/workflows/release-by-develop-hash.yml b/.github/workflows/release-by-develop-hash.yml index 3343b629f..03869809e 100644 --- a/.github/workflows/release-by-develop-hash.yml +++ b/.github/workflows/release-by-develop-hash.yml @@ -118,7 +118,7 @@ jobs: - name: Dispatch Event env: PAT: ${{ secrets.GITHUB_TOKEN }} - ENDPOINT: 'https://api.github.com/repos/fleek-platform/website/dispatches' + ENDPOINT: 'https://api.github.com/repos/${{ github.repository }}/dispatches' EVENT_NAME: 'Release' run: | if ! curl -H "Accept: application/vnd.github+json" \ From 87f696d568ef2e7410a48b95e11c7f5eda671f70 Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Wed, 5 Mar 2025 16:15:41 +0000 Subject: [PATCH 10/13] =?UTF-8?q?chore:=20=F0=9F=A4=96=20add=20=5Fredirect?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/_redirects | 1 + 1 file changed, 1 insertion(+) create mode 100644 public/_redirects diff --git a/public/_redirects b/public/_redirects new file mode 100644 index 000000000..277117e72 --- /dev/null +++ b/public/_redirects @@ -0,0 +1 @@ +/dashboard/* /dashboard/index.html 200 From 9313c4b1acd509cdbed9403c25811cac5076fa33 Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Wed, 5 Mar 2025 19:05:05 +0000 Subject: [PATCH 11/13] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20revision=20ove?= =?UTF-8?q?r=20environment=20variable=20settings=20from=20github=20dashboa?= =?UTF-8?q?rd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/fleek-deploy-common.yml | 24 +++++++++++++---------- .gitignore | 3 +++ package-lock.json | 11 ++++++----- package.json | 4 ++-- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.github/workflows/fleek-deploy-common.yml b/.github/workflows/fleek-deploy-common.yml index 28098b69a..59454f6dd 100644 --- a/.github/workflows/fleek-deploy-common.yml +++ b/.github/workflows/fleek-deploy-common.yml @@ -13,11 +13,15 @@ jobs: runs-on: ubuntu-latest environment: ${{ inputs.environment }} env: + DASHBOARD_UNARCHIVED_PATH: "temp/dashboard" + FLEEK_PROJECT_ID: ${{ env.FLEEK_PROJECT_ID }} + FLEEK_SLUG: ${{ env.FLEEK_SLUG }} FLEEK_TOKEN: ${{ secrets.FLEEK_TOKEN }} - FLEEK_PROJECT_ID: ${{ secrets.FLEEK_PROJECT_ID }} - FLEEK_SLUG: ${{ secrets.FLEEK_SLUG }} + GITHUB_SOURCE_REPO: ${{ github.repository }} + DOPPLER_CONFIG: ${{ env.DOPPLER_CONFIG }} + DOPPLER_PROJECT: ${{ env.DOPPLER_PROJECT }} DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }} - DASHBOARD_UNARCHIVED_PATH: "temp/dashboard" + TARGET_ENVIRONMENT: ${{ inputs.environment }} steps: - name: Checkout uses: actions/checkout@v4 @@ -33,9 +37,9 @@ jobs: - name: Setup Doppler run: | - doppler configure set token ${{ secrets.DOPPLER_TOKEN }} - doppler configure set project ${{ secrets.DOPPLER_PROJECT }} - doppler configure set config ${{ secrets.DOPPLER_CONFIG }} + doppler configure set token "$DOPPLER_TOKEN" + doppler configure set project "$DOPPLER_PROJECT" + doppler configure set config "$DOPPLER_CONFIG" - name: Env vars health check run: | @@ -64,8 +68,8 @@ jobs: id: download_dashboard_artifact run: | github_token="$GITHUB_TOKEN" - source_repo="fleek-platform/dashboard" - dashboard_build_output_filename="build-output-fleek-dashboard-staging" + source_repo="$GITHUB_SOURCE_REPO" + dashboard_build_output_filename="build-output-fleek-xyz-$TARGET_ENVIRONMENT" latest_artifact_file="$dashboard_build_output_filename.zip" .scripts/download_artifact \ @@ -91,8 +95,8 @@ jobs: - name: Setup fleek.config.json run: | - DIST="out" - BUILD="npm run build:ci && cp -r $DASHBOARD_UNARCHIVED_PATH $DIST" + DIST="dist" + BUILD="npm run build && cp -r $DASHBOARD_UNARCHIVED_PATH $DIST" ./scripts/setup-fleek-config \ "$FLEEK_SLUG" \ diff --git a/.gitignore b/.gitignore index 233ce0747..3f60893c5 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,6 @@ fleek.*.config.json #lock files pnpm-lock.yaml + +# dev +dev_* diff --git a/package-lock.json b/package-lock.json index 21e4ac06e..de0290f79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@astrojs/sitemap": "^3.1.4", "@astrojs/tailwind": "^5.1.0", "@fleek-platform/agents-ui": "^4.6.4", - "@fleek-platform/login-button": "^2.2.0", + "@fleek-platform/login-button": "^2.5.0", "@fleek-platform/utils-token": "^0.2.2", "@fleekxyz/sdk": "^0.7.3", "@hookform/resolvers": "^3.9.1", @@ -3288,14 +3288,16 @@ } }, "node_modules/@fleek-platform/login-button": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@fleek-platform/login-button/-/login-button-2.2.0.tgz", - "integrity": "sha512-gHR+8/8bszXuPhjj5RxegVMpUQpoD9YLz9xtnpH5nVmzdiRKhN1pgYLPXkKV+3athrGW97OhCA72CXXYRe4rwg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@fleek-platform/login-button/-/login-button-2.5.0.tgz", + "integrity": "sha512-+HUjTTlQenvUfzqFPF5nF7JRTEVS+7WFF7ocAYs7iW5HKfbmetyXwGcaV8mbCKjCCA3B389aEckG1UUnXCIKrg==", "dependencies": { "@dynamic-labs/ethereum": "3.9.2", "@dynamic-labs/sdk-react-core": "3.9.2", "@fleek-platform/utils-token": "^0.2.2", + "@types/lodash-es": "^4.17.12", "dotenv": "^16.4.7", + "lodash-es": "^4.17.21", "react": "^18.3.1", "react-dom": "^18.3.1", "viem": "^2.21.55", @@ -6933,7 +6935,6 @@ "version": "4.17.12", "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.12.tgz", "integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==", - "dev": true, "dependencies": { "@types/lodash": "*" } diff --git a/package.json b/package.json index d9e386adf..6ff8a5469 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "dev": "astro dev", "start": "astro dev", "build": "rm -rf dist && npm run check:strict && npm run check:json && npm run build:static_assets", - "build:static_assets": "astro build && ./scripts/build/copy-video-content-src-to-dist", + "build:static_assets": "astro build && ./scripts/build/copy-video-content-src-to-dist && cp ./public/_redirects ./dist", "preview": "astro preview", "astro": "astro", "clean": "rm -rf .astro node_modules/.vite", @@ -53,7 +53,7 @@ "@astrojs/sitemap": "^3.1.4", "@astrojs/tailwind": "^5.1.0", "@fleek-platform/agents-ui": "^4.6.4", - "@fleek-platform/login-button": "^2.2.0", + "@fleek-platform/login-button": "^2.5.0", "@fleek-platform/utils-token": "^0.2.2", "@fleekxyz/sdk": "^0.7.3", "@hookform/resolvers": "^3.9.1", From 6d79eb2590980acda121bfeefcfba102f166eb76 Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Thu, 6 Mar 2025 12:49:32 +0000 Subject: [PATCH 12/13] =?UTF-8?q?chore:=20=F0=9F=A4=96=20comment=20out=20p?= =?UTF-8?q?roduction=20version=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/fleek-deploy-production.yml | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/workflows/fleek-deploy-production.yml b/.github/workflows/fleek-deploy-production.yml index b3ed7cb30..59ea490f2 100644 --- a/.github/workflows/fleek-deploy-production.yml +++ b/.github/workflows/fleek-deploy-production.yml @@ -1,17 +1,19 @@ -name: ⚑️ Deploy Dashboard (Production) +# TODO: Once satisfied with staging setup uncomment the following workflow -on: - workflow_dispatch: - push: - branches: - - main - # The workflow's dispatched on Release by develop hash - repository_dispatch: - types: [Release] +# name: ⚑️ Deploy Dashboard (Production) -jobs: - deploy-to-staging: - uses: ./.github/workflows/fleek-deploy-common.yml - with: - environment: production - secrets: inherit +# on: +# workflow_dispatch: +# push: +# branches: +# - main +# # The workflow's dispatched on Release by develop hash +# repository_dispatch: +# types: [Release] + +# jobs: +# deploy-to-staging: +# uses: ./.github/workflows/fleek-deploy-common.yml +# with: +# environment: production +# secrets: inherit From 8999e3d038462b4f260275fbfd60bb3cd9de9a68 Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Thu, 6 Mar 2025 13:49:29 +0000 Subject: [PATCH 13/13] =?UTF-8?q?chore:=20=F0=9F=A4=96=20add=20TODO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/fleek-deploy-common.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/fleek-deploy-common.yml b/.github/workflows/fleek-deploy-common.yml index 59454f6dd..1fa447d11 100644 --- a/.github/workflows/fleek-deploy-common.yml +++ b/.github/workflows/fleek-deploy-common.yml @@ -64,6 +64,9 @@ jobs: - name: Install Packages run: npm install + #Β TODO: It might be wiser to use a regular + # NPM package deployment and copy distribution + # to the local path - name: Download Dashboard artifact id: download_dashboard_artifact run: |