- Understand how to configure a simple Continous Deployment system using Nx and GitHub actions
- Learn how to expose custom secrets on GitHub to your CD processes
-
Add a
.github/workflows/deploy.yml
file -
Using your
ci.yml
config as an example, see if you can configure automated deployments from themain
branch:Anytime we push or merge something to the
main
branch it:- builds the
store
andapi
for production - deploys the
store
andapi
We'll start you off:
name: Deploy Website on: push: branches: - main <-- workflow will run everytime we push or merge something to main jobs: build: runs-on: ubuntu-latest name: Deploying apps steps: .... <-- ADD THE STEPS HERE
- builds the
-
Our "deploy" targets are using some secret ENV variables though. We'll need to make these available on GitHub:
- Go to your GitHub workshop repo
- Click on "Settings" at the top
- Then "Secrets" on the left menu bar
- Add values for all the variables we've been keeping in
.local.env
files
- Then back in our
deploy.yml
file, let's expose these secrets to the processes (useci.yml
as an example of where to put these):
env:
SURGE_DOMAIN_STORE: ${{ secrets.SURGE_DOMAIN_STORE }}
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
NX_API_URL: https://<your-app-name>.fly.dev
-
Since we'll be re-deploying, we want to test if we're looking at a new version of our code:
- Make a change to your API (maybe change the name of one of the games)
- Make a change to your Store (maybe change the title in the header)
-
Commit everything locally on
main
and then push (it's important we push to themain
branch as that's where our workflow runs) -
You should see your new workflow start up under the "Actions" tab on your GitHub repo
-
Once it's done, navigate to your frontend Surge deployment URL and test if you notice the new changes (the ones you made to the Store and also to the API)
🎓 If you get stuck, check out the solution