-
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.
(Add): - Adding GitHub Actions workflow for CONSORCIO API
- Loading branch information
1 parent
c223666
commit 75652e8
Showing
1 changed file
with
64 additions
and
0 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,64 @@ | ||
name: CONSORCIO API CI/CD | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Step 1: Checkout code from the repository | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# Step 2: Set up .NET environment | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 6.0 # Specify .NET 6.0 from your .csproj file | ||
|
||
# Step 3: Restore dependencies | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
|
||
# Step 4: Build the project | ||
- name: Build | ||
run: dotnet build --no-restore --configuration Release | ||
|
||
# Step 5: Run tests (optional) | ||
- name: Run tests | ||
run: dotnet test --no-build --verbosity normal | ||
|
||
# Step 6: Publish the project | ||
- name: Publish | ||
run: dotnet publish -c Release -o out | ||
|
||
docker: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Step 1: Checkout code | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# Step 2: Log in to Docker Hub (replace credentials) | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
# Step 3: Build the Docker image | ||
- name: Build Docker image | ||
run: docker build -f Dockerfile -t your-dockerhub-username/consorcio-api:latest . | ||
|
||
# Step 4: Push the Docker image to Docker Hub | ||
- name: Push Docker image | ||
run: docker push your-dockerhub-username/consorcio-api:latest |