Deploy to AWS Bucket #66
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
env: | |
SHELL: /bin/bash | |
GP_REPO_PATH: tanayseven.github.io/ | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Python | |
uses: actions/setup-python@v2.3.1 | |
with: | |
python-version: "3.10" | |
- name: Install all the dependencies | |
run: | | |
echo "Installed Python version: "`python --version` | |
pip install -r requirements.txt | |
- name: Build the project | |
run: | | |
export GOOGLE_ANALYTICS_ID=${{ secrets.GOOGLE_ANALYTICS_ID }} | |
make clean && make html | |
- name: Setup Github config | |
run: | | |
git config --global user.email "action@github.com" | |
git config --global user.name "GitHub Action" | |
- name: Clone the Github pages repository | |
run: git clone https://${{ secrets.GH_TOKEN }}@github.com/tanayseven/tanayseven.github.io.git | |
- name: Deploy to Github pages | |
run: | | |
rsync -avzh _build/html/* $GP_REPO_PATH | |
rsync -avzh _build/html/.[^.]* $GP_REPO_PATH | |
cd $GP_REPO_PATH | |
git add . | |
git commit -m "`git status --porcelain`" || echo "Nothing new in the branch, nothing will be deployed" | |
git push | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v2.5.0 | |
with: | |
node-version: 16.6.1 | |
- name: Run lighthouse performance | |
run: | | |
npx --yes lighthouse-badges --version | |
npx --yes lighthouse-badges --urls https://tanayseven.com/ -o test_results | |
- name: Install Netlify CLI | |
run: npm install netlify-cli -g | |
- name: Publish the performance badges to Netlify | |
run: netlify deploy --auth=${{ secrets.NETLIFY_TOKEN }} --dir=test_results/ --site=tanayseven-badges-personal-website.netlify.app | |
- name: Deploy to AWS bucket | |
run: aws s3 sync _build/html s3://blog.tanay.tech --delete | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: us-east-1 |