How to Sync an S3 Bucket with GitHub Actions
An Abbreviated Guide to Navigating Github Actions

Developer Advocate @ GitHub
Search for a command to run...
An Abbreviated Guide to Navigating Github Actions

Developer Advocate @ GitHub
I'm glad it was helpful! I forgot I wrote this post.
Wow this one made my head hurt 😅 but now I'm sure I can put this into practice! So smart
LOL thank you. You definitely can.
In this series, I will document technical tutorials for navigating GitHub's awesome features!
Have you ever spent all day searching through commits for a bug? Use this git bisect to literally cut your time in half!
Raise your hand if you've been personally victimized by the question: 'Will AI replace software engineers?' It's a common debate that drives developers to extremes—either avoiding AI entirely or frantically signing up for every AI course available. ...
I recently went down several rabbit holes about building WYSIWYG editors and popovers. While on maternity leave, I finally have time to deeply explore random technical problems without deadlines - a rare opportunity. Thus far, I've focused on contrib...
This blog post uses storytelling to introduce beginners to Verifiable Credentials, followed by a tutorial on creating them in JavaScript and Kotlin. In Our Last Issue... In our previous issue, we met Dawson Webhart, a junior frontend software enginee...

"Our current credit system says, 'Saddle yourself, so we can give you more to saddle.'" Eric Lapin, President of FormFree, stated during a recent TBD live stream. His comment sheds light on a fundamental paradox of the U.S. credit system: it often re...

Technology adoption doesn't happen with one software engineer coding in solitude. Even though big companies like Meta and Microsoft boast of their humble beginnings in a dorm room or a garage, product adoption requires good marketing. Many software e...

Black Girl Bytes
58 posts
I'm a Developer Advocate at GitHub. I'm passionate about community, code, and education! Reach out to me on Twitter ❤️
People often ask me what part of the stack do you prefer, and for fear of pigeonholing myself too early in my career, I always say, “I like it all!” It’s not necessarily a lie, but in this moment, I can honestly admit that the tickets I get most excited about include:
Basically, the key to my heart is through Front end, Databases, or DevOps.
Initial excitement of one of my first encounters with AWS
My love language for programming languages is complaining
More complaining LOL
And even more complaining. In my defense, it was pretty confusing!
Annnnnnd then realizing how much I actually loved and missed AWS lol
It’s safe to say I have more of a love/hate relationship with AWS as I do with most technologies.
Obviously, I missed using AWS, so I was excited when my manager asked me if I wanted to pick up a ticket that involved tinkering with AWS and GitHub.

The problem: When people on our team need to add new assets to the codebase, we often have to upload the assets to AWS S3, but sometimes we have to request access or temporarily update permissions, which feels like a time sink and creates unnecessary blockers. Instead, it would be nice if we could:
The solution (suggested by my manager): GitHub Actions
Although I knew that my company used GitHub Actions, I wasn’t really sure what it was because I had never personally used it, so I set out to answer a few questions:

GitHub Actions is a tool that conveniently enables you to automate custom workflows inside of your GitHub repository. While there is an option to write actions on your own, there is a marketplace filled with already made actions created by developers around the world. Organizations commonly use GitHub Actions for repeated tasks such as, checking for passing tests and release management.
Essentially, you can trigger a workflow to run a set of jobs when a specified event occurs in your repository.


As I mentioned earlier, a workflow is a collection of jobs, and a job is a collection of steps. Containerizing steps within a job enables you to configure how and when steps run. By default, jobs run in parallel, but you can run a job sequentially by depending on the result of other jobs. GitHub’s documentation explains how to assign and use a job_id to run your jobs sequentially.
To write your own workflow for GitHub Actions, you need to create a folder at the root of your project named .github/workflows/
Inside the directory is where you will store your workflows. Each workflow is written using YAML syntax.
Conveniently, I didn't have to write any of my own actions. I found an action on GitHub that did exactly what I wanted. It was called GitHub Action to Sync S3 Bucket. I simply copied and pasted the pre-written code and followed the directions in the ReadMe.
- name: run s3-sync
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete --exclude '.git/*' --exclude '.github/*'
env:
AWS_S3_BUCKET: ${{ format('botany-nudge-assets-{0}', env.ENVIRONMENT_NAME) }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: './nudges/assets'
I did have to preface the prewritten action with a few more instructions to ensure that the workflow ran when desired:
name: s3-sync
on:
push:
branches:
- dev
- production
paths:
- 'folder/path/**'
This defines the name of the workflow.
name: s3-sync
This refers to the event that will trigger the workflow, so my workflow will only run if a push event occurs.
on:
push:
This refers to the branches in which this workflow will occur. My workflow will only be triggered if the event occurs on the dev or production branches.
branches:
- dev
- production
My workflow will only occur if there are changes to a specific directory.
paths:
- 'folder/path/**'
To summarize, I customized my workflow to run when someone pushes a change to a specified directory on a dev or production branch.
The one disadvantage I found with using GitHub Actions is the amount of time it takes to test. To ensure my script was working the way I intended, I had to make a pull request and wait for the action to run after each commit. This resulted in 99+ commits! (Disclaimer: I squashed all these commits before merging). To avoid having a million commits, you can test your action locally with this nifty tool.

Reading logs can often feel like finding a needle in a haystack. That experience is not that different for GitHub Actions, but there are few pros such as:

After I resolved all the failures, I had one more check left. Ensuring that the assets from my directory synced with the s3 bucket. I hesitantly logged into AWS, headed over to Amazon S3, and opened the target s3 bucket.
DUN, DUN, DUN….
The bucket was filled with all the intended assets!

I was so happy that I was able to complete a successful run! Overall, it was a great experience (even though not that much AWS was involved). It’s okay because I learned something new. GitHub Actions is fast, lightweight, convenient, and open-source, so you’re rarely ever starting from scratch. My favorite feature is that it allows you to write expressions, variables, and conditional statements, which makes the tooling seem limitless.
Here’s an example of how I used conditional statements to execute different actions depending on the environment name:
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
if: env.ENVIRONMENT_NAME == 'staging'
env:
AWS_S3_BUCKET: ${{ secrets.STAGING_NUDGE_ASSET_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: './nudges/assets'
- name: run s3-sync on prod
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
if: env.ENVIRONMENT_NAME == 'production'
env:
AWS_S3_BUCKET: ${{ secrets.PRODUCTION_NUDGE_ASSET_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: './nudges/assets'
If you’re looking for a quick guide to GitHub Actions, check out the link below: https://github.github.io/actions-cheat-sheet/actions-cheat-sheet.pdf
And here is a video playlist guide to GitHub Actions from GitHub Dev Advocate, Brian Douglas.
-- Rizel B.