https://github.com/18-ashish-sharma/react-terraform-azure-githubActions
Deploy ReactJS app to Azure Blob Storage through GitHub Actions using Terraform
https://github.com/18-ashish-sharma/react-terraform-azure-githubActions
azure githubaction-workflow reactjs terrform
Last synced: 8 months ago
JSON representation
Deploy ReactJS app to Azure Blob Storage through GitHub Actions using Terraform
- Host: GitHub
- URL: https://github.com/18-ashish-sharma/react-terraform-azure-githubActions
- Owner: 18-ashish-sharma
- Created: 2022-04-07T02:38:22.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-30T08:53:11.000Z (over 1 year ago)
- Last Synced: 2024-11-08T11:46:29.826Z (about 1 year ago)
- Topics: azure, githubaction-workflow, reactjs, terrform
- Language: HCL
- Homepage:
- Size: 923 KB
- Stars: 1
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Deploy ReactJS app to Azure Blob Storage through GitHub Actions using Terraform
Create a simple React app
Choose a suitable working folder and then execute the following command in a terminal window to create a ReactJS app named react2az:
npx create-react-app react2az --use-npm
cd react2az
npm start
The app will display in your default browser as shown below:

Run your application and you should experience the following web page:

Push ReactJS app to GitHub
Note that your application already contains a .gitignore file. This means that the node_modules folder will be excluded for being pushed to GitHub.
Create a local git repo by running the following command in the root of your application:
git init
git add .
git commit -m "1st commit"
Using Terraform a resource group, a storage and a blob container will get created.
Click on "Go to resource". In the search field, enter the word static then click on "Static website".

Click on enabled

Click on your browser back button, clear the search field, then select "Access keys".

Click on "Show keys", copy the connection string, then temporarily paste it in a a text editor.
GitHub Actions
In GitHub, click on Settings:

Create a key named AZURE_STORAGE then paste the connection string that you previously saved in a text editor. Click on "Add secret".

Add all these secrets:
Run these commands:
az login
az ad sp create-for-rbac --name "sp-hello-azure-tf" --role Contributor --scopes /subscriptions/{subscriptionID} --sdk-auth

After this github actions will run:


Viewing our web application
You must be dying to view the application hosted on Azure. Return to the Azure portal then go to "static websites". The URL for accessing your application is beside "Primary endpoint".

Visit the primary endpoint URL and you will see that your ReactJS app is happily hosted on Azure:
