Skip to content

feat: added change

feat: added change #63

Workflow file for this run

name: Build, Deploy to S3, and Create Release
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build_and_deploy:
name: Build and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout main repository and submodules
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.GH_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install dependencies
run: yarn install
- name: Build the project
run: yarn run build
- name: Upload to S3
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
run: |
aws s3 cp ./dist/app.min.js s3://${{ secrets.S3_BUCKET_NAME }}/public/scripts/app.min.js \
--region $AWS_REGION --acl public-read
- name: Invalidate CloudFront cache
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
run: |
aws cloudfront create-invalidation \
--distribution-id E3SJXANXL6IYCB \
--paths "/public/scripts/*"
create_release:
name: Create Release
needs: build_and_deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version and create tag
id: version
run: |
VERSION="0.1.$(date +%Y%m%d)-$(git rev-parse --short HEAD)"
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "TAG_NAME=v${VERSION}" >> $GITHUB_OUTPUT
if git tag -l "v${VERSION}" | grep -q "v${VERSION}"; then
echo "TAG_EXISTS=true" >> $GITHUB_OUTPUT
else
echo "TAG_EXISTS=false" >> $GITHUB_OUTPUT
fi
- name: Create and push tag
if: steps.version.outputs.TAG_EXISTS == 'false'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.version.outputs.TAG_NAME }}" -m "Release ${{ steps.version.outputs.TAG_NAME }}"
git push origin "${{ steps.version.outputs.TAG_NAME }}"
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "# Release ${{ steps.version.outputs.TAG_NAME }}" > release-notes.md
echo "" >> release-notes.md
echo "## Changes" >> release-notes.md
echo "- Automated release from commit $(git rev-parse --short HEAD)" >> release-notes.md
gh release create "${{ steps.version.outputs.TAG_NAME }}" \
--title "Release ${{ steps.version.outputs.TAG_NAME }}" \
--notes-file release-notes.md