-
Notifications
You must be signed in to change notification settings - Fork 260
docs(tutorial): Create GitHub action to sync object storage #4586
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
Merged
SamyOubouaziz
merged 26 commits into
scaleway:main
from
LLejoly:ext-add-tutorial-cicd-github-action-object-storage-sync
Mar 31, 2025
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
fe19950
feat(tutorial): GitHub action to sync object storage
LLejoly e2f7535
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly 4a5b98c
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly 506428d
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly f0c2381
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly 21e470a
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly 835cd1c
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly 4dbf179
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly cfda2c8
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly 111f23d
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly 599f6d2
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly 44344c7
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly 2ad0c1a
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly 690f418
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly a1f7269
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly 6ce2584
Merge branch 'scaleway:main' into ext-add-tutorial-cicd-github-action…
LLejoly 43a85ef
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly 0690faf
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly ccc9783
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly c9f78fd
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly 9321334
Update tutorials/cicd-github-action-object-storage-sync/index.mdx
LLejoly b76035f
Update index.mdx
LLejoly 5db5ebf
Merge branch 'scaleway:main' into ext-add-tutorial-cicd-github-action…
LLejoly 9b910ce
Update index.mdx
LLejoly d85ca40
Update index.mdx
LLejoly 87913f1
Apply suggestions from code review
SamyOubouaziz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
114 changes: 114 additions & 0 deletions
114
tutorials/cicd-github-action-object-storage-sync/index.mdx
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| --- | ||
| meta: | ||
| title: Github Action Sync Object Storage | ||
| description: Github action explaining how to sync files content with a Storage account using a github action | ||
| content: | ||
| h1: Using Github action to Sync your files with Object Storage | ||
| paragraph: This page explains how to configure your github action to sync your files with an Object storage | ||
| tags: CI/CD Github Action Object Storage | ||
| categories: | ||
| - object-storage | ||
| dates: | ||
| validation: 2025-03-10 | ||
| posted: 2025-03-10 | ||
| --- | ||
|
|
||
| ## Tutorial: Deploying your content to Scaleway Object Storage Using GitHub Actions | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| This tutorial will guide you through setting up a GitHub Action to deploy your Astro site to Scaleway Object Storage. We will use a GitHub Actions workflow to automate the deployment process whenever changes are pushed to the `main` branch. | ||
|
|
||
| ## Prerequisites | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - A GitHub repository with your Astro project. | ||
| - A Scaleway account with Object Storage configured. | ||
| - Scaleway API credentials (Access Key, Secret Key, Project ID, Organization ID). | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Step 1: Create the GitHub Action Workflow | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 1. In your GitHub repository, navigate to the `.github/workflows` directory. If it doesn't exist, create it. | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 2. Create a new file named `deploy.yml` in the `.github/workflows` directory. | ||
|
|
||
| ## Step 2: Define the Workflow | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Copy and paste the following code into the `deploy.yml` file. This workflow will run on every push to the `main` branch, build your Astro site, and upload the built files to Scaleway Object Storage. | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```yaml | ||
| name: Upload to Scaleway Object Storage | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main # Change this to your default branch if different | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| jobs: | ||
| upload: | ||
| environment: prd | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| uses: actions/checkout@v2 | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: '23' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm install | ||
|
|
||
| - name: Build the website | ||
| run: npm run build | ||
|
|
||
| - name: Install s3cmd | ||
| run: sudo apt-get install -y s3cmd | ||
|
|
||
| - name: Install CLI | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| uses: scaleway/action-scw@v0 | ||
| with: | ||
| version: v2.37.0 | ||
|
|
||
| - run: | | ||
| scw object config get type=s3cmd > /home/runner/.s3cfg | ||
| s3cmd --no-mime-magic --guess-mime-type sync ./dist/* s3://your_bucket_name/ | ||
| env: | ||
| SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }} | ||
| SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }} | ||
| SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }} | ||
| SCW_DEFAULT_ORGANIZATION_ID: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }} | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| ## Step 3: Configure Secrets | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| In your GitHub repository, go to Settings > Secrets and variables > Actions. | ||
| Add the following secrets with your Scaleway credentials: | ||
|
|
||
| - SCW_ACCESS_KEY | ||
| - SCW_SECRET_KEY | ||
| - SCW_DEFAULT_PROJECT_ID | ||
| - SCW_DEFAULT_ORGANIZATION_ID | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Step 4: Commit and Push | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Commit and push the `deploy.yml` file to your repository. This will trigger the GitHub Action to run on the main branch. | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```bash | ||
| git add .github/workflows/deploy.yml | ||
| git commit -m "Add GitHub Action for deploying to Scaleway Object Storage" | ||
| git push origin main | ||
| ``` | ||
| ### Notes: | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| #### Alternative Build Processes | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| If your project uses a different build process, replace the `Install dependencies`and `Build the website` steps with the appropriate commands for your environment. | ||
|
|
||
| Here are some examples: | ||
| ```python | ||
LLejoly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v5 | ||
|
|
||
| - name: Install the project | ||
| run: uv sync --all-extras --dev | ||
| - name: Build the project | ||
| run: uv build | ||
| ``` | ||
LLejoly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.