-
Notifications
You must be signed in to change notification settings - Fork 0
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
cf17ef3
commit 903246a
Showing
4 changed files
with
96 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Pipeline CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
- feat/deploy | ||
|
||
permissions: write-all | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: rafaellevissa/bank-webapp:latest | ||
APP_NAME: react-relay-graphql | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [22.x] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
|
||
uses: actions/setup-node@v3n | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Installing Dependencies | ||
run: npm install | ||
|
||
- name: Create dotenv | ||
run: echo "${{ secrets.ENV }}" | base64 --decode > .env | ||
|
||
- run: npm run test | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
needs: tests | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login to Github Registrey | ||
if: success() | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create dotenv | ||
run: echo "${{ secrets.ENV }}" | base64 --decode > .env | ||
|
||
- name: Build image api | ||
run: docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} . | ||
|
||
- name: Publish image api | ||
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: EC2 Deployment | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USERNAME }} | ||
key: ${{ secrets.EC2_SSH_PRIVATE_KEY }} | ||
script: |- | ||
docker container stop ${{ env.APP_NAME}} || true | ||
docker container rm ${{ env.APP_NAME}} || true | ||
docker login ${{ env.REGISTRY }} -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} | ||
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
docker run -d --net host --restart=unless-stopped --name ${{ env.APP_NAME}} ${{ env.REGISTRY }}/${{ env.IMAGE_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
package-lock.json | ||
package-lock.json | ||
dist |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM node:22-alpine3.19 AS builder | ||
|
||
WORKDIR /opt/app | ||
|
||
COPY package*.json . | ||
|
||
RUN npm i && npm i -g serve | ||
|
||
COPY . . | ||
|
||
RUN npm run build | ||
|
||
ENTRYPOINT [ "serve", "./dist", "-l", "tcp://0.0.0.0:5173"] | ||
|