Merge pull request #69 from Triumers/dev #173
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: Node.js CI And Deploy | |
on: | |
push: | |
branches: [ "main", "dev" ] | |
pull_request: | |
branches: [ "main", "dev" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [21.x] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- run: npm ci | |
- run: npm run build --if-present | |
- name: Install AWS CLI | |
run: | | |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | |
unzip awscliv2.zip | |
sudo ./aws/install --update | |
- 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-northeast-2 | |
- name: Generate deployment package | |
run: | | |
mkdir -p deploy | |
cp -r dist deploy/ # dist 디렉토리를 포함 | |
cp package.json deploy/ | |
cp server.js deploy/ | |
cp Procfile deploy/Procfile | |
cd deploy && zip -r deploy.zip . | |
- name: Build Number | |
id: build-number | |
run: | | |
echo "::set-output name=BUILD_NUMBER::$(date '+%-d.%-m.%Y.%-H.%-M.%-S')" | |
- name: Beanstalk Deploy | |
uses: einaregilsson/beanstalk-deploy@v22 | |
with: | |
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
application_name: Triumers-Front | |
environment_name: Triumers-Front-env | |
version_label: ${{ steps.build-number.outputs.BUILD_NUMBER }} | |
version_description: Version ${{ steps.build-number.outputs.BUILD_NUMBER }} deployed via github actions ${{ github.sha }} | |
region: ap-northeast-2 | |
deployment_package: deploy/deploy.zip |