Skip to content

Commit fe19950

Browse files
authored
feat(tutorial): GitHub action to sync object storage
Tutorial explaining how to create a GitHub action to sync with object storage
1 parent 0a99e57 commit fe19950

File tree

1 file changed

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

1 file changed

+114
-0
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
meta:
3+
title: Github Action Sync Object Storage
4+
description: Github action explaining how to sync files content with a Storage account using a github action
5+
content:
6+
h1: Using Github action to Sync your files with Object Storage
7+
paragraph: This page explains how to configure your github action to sync your files with an Object storage
8+
tags: CI/CD Github Action Object Storage
9+
categories:
10+
- object-storage
11+
dates:
12+
validation: 2025-03-10
13+
posted: 2025-03-10
14+
---
15+
16+
## Tutorial: 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+
## Prerequisites
21+
22+
- A GitHub repository with your Astro project.
23+
- A Scaleway account with Object Storage configured.
24+
- Scaleway API credentials (Access Key, Secret Key, Project ID, Organization ID).
25+
26+
## Step 1: Create the GitHub Action Workflow
27+
28+
1. In your GitHub repository, navigate to the `.github/workflows` directory. If it doesn't exist, create it.
29+
2. Create a new file named `deploy.yml` in the `.github/workflows` directory.
30+
31+
## Step 2: Define the Workflow
32+
33+
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.
34+
35+
```yaml
36+
name: Upload to Scaleway Object Storage
37+
38+
on:
39+
push:
40+
branches:
41+
- main # Change this to your default branch if different
42+
43+
jobs:
44+
upload:
45+
environment: prd
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v2
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 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_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
78+
SCW_DEFAULT_ORGANIZATION_ID: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }}
79+
```
80+
81+
## Step 3: Configure 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_DEFAULT_PROJECT_ID
89+
- SCW_DEFAULT_ORGANIZATION_ID
90+
91+
## Step 4: Commit and Push
92+
93+
Commit and push the `deploy.yml` file to your repository. 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+
### Notes:
101+
102+
#### Alternative Build Processes
103+
If your project uses a different build process, replace the `Install dependencies`and `Build the website` steps with the appropriate commands for your environment.
104+
105+
Here are some examples:
106+
```python
107+
- name: Install uv
108+
uses: astral-sh/setup-uv@v5
109+
110+
- name: Install the project
111+
run: uv sync --all-extras --dev
112+
- name: Build the project
113+
run: uv build
114+
```

0 commit comments

Comments
 (0)