Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Switch on aws s3 copy, fix typo #3210

Merged
merged 6 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 17 additions & 25 deletions .github/workflows/cli-r2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,43 +41,35 @@ jobs:
run: pnpm install --ignore-scripts

- name: pnpm build
run: pnpm --filter 'webstudio-cloudlfare-template^...' run build
run: pnpm --filter 'webstudio-cloudflare-template^...' run build

# Ideally, execute 'pnpm deploy --prod', but @remix-run/dev doesn't support this flag.
# Despite being listed as a dependency, @remix-run/dev does not install the remix cli.
# TODO: Minimize artefact size due to frequent downloads on each publish.
- name: pnpm deploy
run: pnpm --filter 'webstudio-cloudlfare-template' deploy "${{ github.workspace }}/../cloudlfare-template"
run: pnpm --filter 'webstudio-cloudflare-template' deploy "${{ github.workspace }}/../cloudflare-template"

- name: Make archive
run: |
tar --use-compress-program="zstd -19" -cf cloudlfare-template.tar.zst cloudlfare-template
tar --use-compress-program="zstd -19" -cf cloudflare-template.tar.zst cloudflare-template
working-directory: ${{ github.workspace }}/..

- name: Copy artifact
run: |
curl https://rclone.org/install.sh | sudo bash

ls -la

# For staging
rclone copyto -P -M \
--no-check-dest \
cloudlfare-template.tar.zst "r2:/${ARTEFACT_BUCKET_NAME}/public/cloudlfare-template/${{ github.ref_name }}.tar.zst"
aws s3 cp cloudflare-template.tar.zst "s3://${ARTEFACT_BUCKET_NAME}/public/cloudflare-template/${{ github.ref_name }}.tar.zst"

# For production
rclone copyto -P -M \
--no-check-dest \
cloudlfare-template.tar.zst "r2:/${ARTEFACT_BUCKET_NAME}/public/cloudlfare-template/${{ github.sha }}.tar.zst"
# For production can be cached forever
aws s3 cp \
--metadata-directive REPLACE --cache-control "public,max-age=31536102,immutable" \
cloudflare-template.tar.zst "s3://${ARTEFACT_BUCKET_NAME}/public/cloudflare-template/${{ github.sha }}.tar.zst"

working-directory: ${{ github.workspace }}/..
env:
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.RCLONE_CONFIG_R2_ACCESS_KEY_ID }}
RCLONE_CONFIG_R2_ACL: ${{ secrets.RCLONE_CONFIG_R2_ACL }}
RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.RCLONE_CONFIG_R2_ENDPOINT }}
RCLONE_CONFIG_R2_PROVIDER: ${{ secrets.RCLONE_CONFIG_R2_PROVIDER }}
RCLONE_CONFIG_R2_TYPE: ${{ secrets.RCLONE_CONFIG_R2_TYPE }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.RCLONE_CONFIG_R2_SECRET_ACCESS_KEY }}
AWS_ENDPOINT_URL_S3: ${{ secrets.AWS_ENDPOINT_URL_S3 }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
ARTEFACT_BUCKET_NAME: ${{ secrets.ARTEFACT_BUCKET_NAME }}

checks:
Expand All @@ -98,18 +90,18 @@ jobs:
node-version: "18.x"

- name: Copy atrifact via http
run: curl -o cloudlfare-template.tar.zst ${{ secrets.ARTEFACT_BUCKET_URL }}/public/cloudlfare-template/${{ github.ref_name }}.tar.zst
run: curl -o cloudflare-template.tar.zst ${{ secrets.ARTEFACT_BUCKET_URL }}/public/cloudflare-template/${{ github.ref_name }}.tar.zst

- name: Extract archive
run: tar --use-compress-program="zstd -d" -xf cloudlfare-template.tar.zst -C .
run: tar --use-compress-program="zstd -d" -xf cloudflare-template.tar.zst -C .

- name: Webstudio Build
run: pnpm webstudio build --template internal --template saas-helpers --template cloudflare --assets false
working-directory: ${{ github.workspace }}/cloudlfare-template
working-directory: ${{ github.workspace }}/cloudflare-template

- name: Remix Build
run: pnpm build
working-directory: ${{ github.workspace }}/cloudlfare-template
working-directory: ${{ github.workspace }}/cloudflare-template

- name: WRANGLER Build
run: |
Expand All @@ -122,4 +114,4 @@ jobs:
--outdir dist \
'./functions/[[path]].ts'

working-directory: ${{ github.workspace }}/cloudlfare-template
working-directory: ${{ github.workspace }}/cloudflare-template
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"private": true,
"sideEffects": false,
"name": "webstudio-cloudlfare-template",
"name": "webstudio-cloudflare-template",
"version": "0.0.1",
"description": "",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading