Merge pull request #10 from shreyas1434shinde/resetpassowrds #14
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: S3 Deployment on the Pratham-PROD | |
on: | |
push: | |
tags: | |
- "v*" # Trigger workflow on tag pushes matching the pattern 'v*' | |
branches: | |
- release-1.0.0 # Specify the release branch where tags will trigger the workflow | |
- main | |
jobs: | |
s3_deployment_PROD: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Ensure all tags are fetched | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "20" | |
- name: Set TAG environment variable | |
id: get_tag | |
run: | | |
# Extract the tag from the ref and set it as an environment variable | |
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
- name: Debug TAG value | |
run: | | |
# Print the TAG value to ensure the correct tag is being used | |
echo "TAG value - ${{ env.TAG }}" | |
- name: Checkout to the specific tag | |
run: | | |
# Checkout the code at the specified tag without creating a new branch | |
git checkout tags/${{ env.TAG }} | |
- name: npm install and build | |
run: | | |
ls -ltra | |
if [ -f .env ]; then | |
rm .env | |
fi | |
echo '${{ secrets.PROD_ENV }}' > .env | |
ls -ltra | |
npm install --force | |
npm install --legacy-peer-deps | |
npm run build | |
ls -ltra | |
- name: Show PWD | |
run: | | |
echo "Current Working Directory:" | |
pwd | |
- name: List Contents | |
run: | | |
echo "Contents of the current directory (in reverse order):" | |
ls -lr | |
- name: List Contents | |
run: | | |
echo "Contents of the dist directory (in reverse order):" | |
cd | |
ls -lr | |
- name: Install AWS CLI | |
run: | | |
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y awscli | |
- name: Configure AWS credentials | |
run: | | |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws configure set default.region ${{ secrets.AWS_S3_BUCKET_REGION }} | |
- name: Upload to s3 Bucket | |
run: | | |
aws s3 sync dist s3://${{ secrets.AWS_S3_BUCKET_PROD }}/ | |
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_PROD }} --paths "/*" |