Deploy frontend #7
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: Deploy Resources | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
deploy-frontend: | |
name: Deploy Frontend | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
working-directory: ./frontend | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20.x' | |
- name: Install dependencies | |
run: npm install | |
- name: Build the project | |
run: npm run build | |
- 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: ap-southeast-1 | |
- name: Install AWS Amplify CLI | |
run: npm install -g @aws-amplify/cli | |
- name: Deploy to Amplify | |
run: | | |
amplify init --yes | |
amplify publish --yes | |
create-release: | |
name: Create Release | |
runs-on: ubuntu-latest | |
needs: [ deploy-frontend ] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Prepare release | |
id: prep_release | |
run: | | |
# Example script to generate tag and release notes, needs to be customized | |
TAG_NAME=$(git tag --sort=-v:refname | head -n 1 | awk -F '.' '{print $1 "." $2+1}') | |
if [ -z "$TAG_NAME" ]; then | |
TAG_NAME="1.0" | |
fi | |
RELEASE_NOTES=$(git log $(git describe --tags --abbrev=0)..HEAD --oneline) | |
if [ -z "$RELEASE_NOTES" ]; then | |
RELEASE_NOTES="Initial release" | |
fi | |
echo "::set-output name=tag_name::$TAG_NAME" | |
echo "::set-output name=release_notes::$RELEASE_NOTES" | |
shell: bash | |
- name: Create GitHub Release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.prep_release.outputs.tag_name }} | |
release_name: Release ${{ steps.prep_release.outputs.tag_name }} | |
body: ${{ steps.prep_release.outputs.release_notes }} | |
draft: false | |
prerelease: false | |