Synchronizing your website with Object Storage using GitHub Actions
- ci
- cd
- github
- actions
- object
- storage
- s3cmd
- sync
- workflow
Deploying your content to Scaleway Object Storage Using GitHub Actions
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.
Before you startLink to this anchor
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- A GitHub repository with your Astro project.
- A Scaleway Object Storage bucket with the bucket website feature enabled
- Retrieved your Scaleway credentials (API key, Project ID, Organization ID).
Creating the GitHub Actions WorkflowLink to this anchor
- In your GitHub repository, navigate to the
.github/workflows
directory. If it does not exist, create it at the root of your repository. - Create a new file named
deploy.yml
in the.github/workflows
directory.
Defining the workflowLink to this anchor
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 website, and upload the built files to Scaleway Object Storage.
name: Upload to Scaleway Object Storageon:push:branches:- main # Change this to your default branch if different (e.g. "trunk", or "master")jobs:upload:runs-on: ubuntu-lateststeps:- name: Checkout repositoryuses: actions/checkout@v4- name: Set up Node.jsuses: actions/setup-node@v2with:node-version: '23'- name: Install dependenciesrun: npm install- name: Build the websiterun: npm run build- name: Install s3cmdrun: sudo apt-get install -y s3cmd- name: Install the Scaleway CLIuses: scaleway/action-scw@v0with:version: v2.37.0- run: |scw object config get type=s3cmd > /home/runner/.s3cfgs3cmd --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_PROJECT_ID: ${{ secrets.SCW_PROJECT_ID }}SCW_ORGANIZATION_ID: ${{ secrets.SCW_ORGANIZATION_ID }}
Configure repository secrets
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_PROJECT_ID
- SCW_ORGANIZATION_ID
Commit and push your changes
Run the commands below to commit and push the deploy.yml
file to your repository. If you are working directly on your main branch, this will trigger the GitHub Action to run on the main branch.
git add .github/workflows/deploy.ymlgit commit -m "Add GitHub Action for deploying to Scaleway Object Storage"git push origin main
You can now access your website by clicking the Website URL from the Settings tab of your bucket in the Scaleway console.
Alternative build processesLink to this anchor
If your project uses a different build process, replace the Install dependencies
and Build the website
steps with the appropriate commands for your environment. The code below shows an example of an alternative build process using Astral.
- name: Install uvuses: astral-sh/setup-uv@v5- name: Install the projectrun: uv sync --all-extras --dev- name: Build the projectrun: uv build
Troubleshooting and additional resourcesLink to this anchor
-
If you encounter issues while using your API key with Scaleway Object Storage, refer to the dedicated troubleshooting.
-
Refer to the official GitHub Actions documentation for more information on how to create and run workflows.
-
Learn how to better secure your deployment by properly setting up IAM and Object Storage.