-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b02ab7
commit 636b8f8
Showing
9 changed files
with
38 additions
and
58 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,38 @@ | ||
name: Deploy website and admin panel | ||
name: Deploy website and admin panel on s3 | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- deploy-website-using-s3 | ||
|
||
jobs: | ||
merge: | ||
runs-on: ubuntu-latest | ||
build-and-deploy: | ||
name: Build and Deploy | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Fetch and reset main branch | ||
run: | | ||
git fetch origin main | ||
git checkout main | ||
git reset --hard origin/main | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "20.x" | ||
|
||
- name: Merge website branch to website-main | ||
run: | | ||
git fetch origin | ||
git config user.name github-actions | ||
git config user.email github-actions@github.com | ||
if [ "$(git diff origin/main:website origin/website-main | wc -l)" -gt "0" ]; then | ||
echo "Detected uncommitted changes in the website folder after build. Pushing changes to website-main branch." | ||
git checkout website-main | ||
git rm -r * | ||
git checkout main -- website | ||
git mv website/* . | ||
ls | ||
rm -r website | ||
git add . | ||
git commit -m "Deploy website" | ||
git push origin website-main | ||
else | ||
echo "No changes detected in the website folder after build. Exiting." | ||
fi | ||
- name: Install dependencies and Build website | ||
run: | | ||
cd website | ||
npm install | ||
npm run build | ||
- name: Merge admin branch to admin-main | ||
run: | | ||
git fetch origin | ||
git config user.name github-actions | ||
git config user.email github-actions@github.com | ||
if [ "$(git diff origin/main:admin origin/admin-main | wc -l)" -gt "0" ]; then | ||
echo "Detected uncommitted changes in the admin folder after build. Pushing changes to admin-main branch." | ||
git checkout admin-main | ||
git rm -r * | ||
git checkout main -- admin | ||
git mv admin/* . | ||
ls | ||
rm -r admin | ||
git add . | ||
git commit -m "Deploy admin panel" | ||
git push origin admin-main | ||
else | ||
echo "No changes detected in the admin folder after build. Exiting." | ||
fi | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Deploy to S3 | ||
run: | | ||
cd website | ||
aws s3 sync ./out s3://${{ secrets.WEBSITE_BUCKET_NAME }} |
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
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
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
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
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
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
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
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