Skip to content

Commit d68025a

Browse files
LLejolySamyOubouazizldecarvalho-docjcirinosclwy
authored
docs(tutorial): Create GitHub action to sync object storage (#4586)
* feat(tutorial): GitHub action to sync object storage Tutorial explaining how to create a GitHub action to sync with object storage * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update tutorials/cicd-github-action-object-storage-sync/index.mdx Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> * Update index.mdx Add additional section + change checkout version * Update index.mdx Co-authored-by: ldecarvalho-doc <82805470+ldecarvalho-doc@users.noreply.github.com> * Update index.mdx Co-authored-by: ldecarvalho-doc <82805470+ldecarvalho-doc@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Jessica <113192637+jcirinosclwy@users.noreply.github.com> --------- Co-authored-by: SamyOubouaziz <soubouaziz@scaleway.com> Co-authored-by: ldecarvalho-doc <82805470+ldecarvalho-doc@users.noreply.github.com> Co-authored-by: Jessica <113192637+jcirinosclwy@users.noreply.github.com>
1 parent 576c176 commit d68025a

File tree

1 file changed

+124
-0
lines changed
  • tutorials/cicd-github-action-object-storage-sync

1 file changed

+124
-0
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
meta:
3+
title: Synchronizing your website with Object Storage using GitHub Actions
4+
description: Learn how to automatically sync files from a GitHub repository with Scaleway Object Storage using GitHub Actions to deploy your website
5+
content:
6+
h1: Synchronizing your website with Object Storage using GitHub Actions
7+
paragraph: Learn how to automatically sync files from a GitHub repository with Scaleway Object Storage using GitHub Actions to deploy your website
8+
tags: ci cd github actions object storage s3cmd sync workflow
9+
categories:
10+
- object-storage
11+
dates:
12+
validation: 2025-03-10
13+
posted: 2025-03-10
14+
---
15+
16+
Deploying your content to Scaleway Object Storage Using GitHub Actions
17+
18+
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.
19+
20+
<Macro id="requirements" />
21+
22+
- A Scaleway account logged into the [console](https://console.scaleway.com)
23+
- A [GitHub](https://github.com/) repository with your [Astro](https://astro.build/) project.
24+
- A Scaleway Object Storage bucket with the [bucket website](/object-storage/how-to/use-bucket-website/) feature enabled
25+
- Retrieved your Scaleway credentials ([API key](/iam/how-to/create-api-keys/), Project ID, Organization ID).
26+
27+
## Creating the GitHub Actions Workflow
28+
29+
1. In your GitHub repository, navigate to the `.github/workflows` directory. If it does not exist, create it at the root of your repository.
30+
2. Create a new file named `deploy.yml` in the `.github/workflows` directory.
31+
32+
## Defining the workflow
33+
34+
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.
35+
36+
```yaml
37+
name: Upload to Scaleway Object Storage
38+
39+
on:
40+
push:
41+
branches:
42+
- main # Change this to your default branch if different (e.g. "trunk", or "master")
43+
44+
jobs:
45+
upload:
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
52+
- name: Set up Node.js
53+
uses: actions/setup-node@v2
54+
with:
55+
node-version: '23'
56+
57+
- name: Install dependencies
58+
run: npm install
59+
60+
- name: Build the website
61+
run: npm run build
62+
63+
- name: Install s3cmd
64+
run: sudo apt-get install -y s3cmd
65+
66+
- name: Install the Scaleway CLI
67+
uses: scaleway/action-scw@v0
68+
with:
69+
version: v2.37.0
70+
71+
- run: |
72+
scw object config get type=s3cmd > /home/runner/.s3cfg
73+
s3cmd --no-mime-magic --guess-mime-type sync ./dist/* s3://your_bucket_name/
74+
env:
75+
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }}
76+
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }}
77+
SCW_PROJECT_ID: ${{ secrets.SCW_PROJECT_ID }}
78+
SCW_ORGANIZATION_ID: ${{ secrets.SCW_ORGANIZATION_ID }}
79+
```
80+
81+
Configure repository secrets
82+
83+
In your GitHub repository, go to Settings > Secrets and variables > Actions.
84+
Add the following secrets with your Scaleway credentials:
85+
86+
- SCW_ACCESS_KEY
87+
- SCW_SECRET_KEY
88+
- SCW_PROJECT_ID
89+
- SCW_ORGANIZATION_ID
90+
91+
Commit and push your changes
92+
93+
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.
94+
95+
```bash
96+
git add .github/workflows/deploy.yml
97+
git commit -m "Add GitHub Action for deploying to Scaleway Object Storage"
98+
git push origin main
99+
```
100+
101+
You can now access your website by clicking the **Website URL** from the **Settings** tab of your bucket in the [Scaleway console](https://console.scaleway.com/object-storage/buckets).
102+
103+
## Alternative build processes
104+
105+
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](https://astral.sh/).
106+
107+
108+
```yaml
109+
- name: Install uv
110+
uses: astral-sh/setup-uv@v5
111+
112+
- name: Install the project
113+
run: uv sync --all-extras --dev
114+
- name: Build the project
115+
run: uv build
116+
```
117+
118+
## Troubleshooting and additional resources
119+
120+
- If you encounter issues while using your API key with Scaleway Object Storage, refer to the [dedicated troubleshooting](/object-storage/troubleshooting/api-key-does-not-work/).
121+
122+
- Refer to the [official GitHub Actions documentation](https://docs.github.com/en/actions/writing-workflows/quickstart) for more information on how to create and run workflows.
123+
124+
- Learn how to better secure your deployment by properly [setting up IAM and Object Storage](/object-storage/api-cli/combining-iam-and-object-storage/).

0 commit comments

Comments
 (0)