forked from prasadhonrao/devcamper
-
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.
Merge pull request prasadhonrao#17 from prasadhonrao/feature/api-ci-c…
…d-workflow Set Up CI/CD Pipeline Using GitHub Actions for API project
- Loading branch information
Showing
4 changed files
with
104 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: API - Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'api/**' | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'api/**' | ||
workflow_dispatch: | ||
|
||
env: | ||
DOCKER_IMAGE: prasadhonrao/devcamper-api | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and push Docker image | ||
run: | | ||
docker build -t ${{ env.DOCKER_IMAGE }}:${{ github.sha }} -f api/Dockerfile api | ||
docker tag ${{ env.DOCKER_IMAGE }}:${{ github.sha }} ${{ env.DOCKER_IMAGE }}:latest | ||
docker push ${{ env.DOCKER_IMAGE }}:${{ github.sha }} | ||
docker push ${{ env.DOCKER_IMAGE }}:latest |
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,35 @@ | ||
name: API - Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'api/**' | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'api/**' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install dependencies | ||
run: npm install --prefix api | ||
|
||
- name: Deploy | ||
run: | | ||
# Add your deployment steps here | ||
echo "Deploying the application..." |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
node_modules | ||
npm-debug.log | ||
Dockerfile | ||
.dockerignore | ||
docker-compose.yml | ||
.git | ||
.gitignore | ||
_postman | ||
|