-
Notifications
You must be signed in to change notification settings - Fork 0
ci: test done #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| name: CD | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, testci] | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: write | ||
| actions: write | ||
| deployments: write | ||
| pages: write | ||
| pull-requests: write | ||
| packages: write | ||
|
|
||
| jobs: | ||
| deployment: | ||
| env: | ||
| HUSKY: 0 | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
||
| - uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: "9.0.x" | ||
|
|
||
| - run: cd WebAPI | ||
| - run: ls -al | ||
| - run: dotnet restore ./WebAPI/WebAPI.csproj | ||
|
|
||
| - id: main | ||
| run: dotnet build ./WebAPI/WebAPI.csproj -c Release -o ./build | ||
|
|
||
| - if: ${{ steps.main.outcome == 'failure' }} | ||
| run: exit 1 | ||
|
|
||
| - id: publish | ||
| run: dotnet publish ./WebAPI/WebAPI.csproj -c Release -o ./publish /p:UseAppHost=false | ||
|
|
||
| # Make a lowercase owner for GHCR image path (Docker requires lowercase repo names) | ||
| - name: Compute lowercased owner | ||
| id: vars | ||
| run: echo "OWNER_LC=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Log in to GHCR | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Build and push Docker image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| push: true | ||
| tags: | | ||
| ghcr.io/${{ env.OWNER_LC }}/ev-rental-be:latest | ||
| ghcr.io/${{ env.OWNER_LC }}/ev-rental-be:${{ github.sha }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,37 @@ | ||||
| name: CI | ||||
|
|
||||
| on: | ||||
| pull_request: | ||||
| types: [synchronize, opened, reopened, edited] | ||||
|
|
||||
| permissions: | ||||
| id-token: write | ||||
| contents: write | ||||
| actions: write | ||||
| deployments: write | ||||
| pages: write | ||||
| pull-requests: write | ||||
| packages: write | ||||
|
|
||||
| jobs: | ||||
| main-ci: | ||||
| env: | ||||
| HUSKY: 0 | ||||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||
| runs-on: ubuntu-latest | ||||
| steps: | ||||
| - uses: actions/checkout@v5 | ||||
|
|
||||
| - uses: actions/setup-dotnet@v5 | ||||
| with: | ||||
| dotnet-version: "9.0.x" | ||||
|
|
||||
| - run: cd WebAPI | ||||
| - run: ls -al | ||||
| - run: dotnet restore ./WebAPI/WebAPI.csproj | ||||
|
||||
| - run: dotnet restore ./WebAPI/WebAPI.csproj |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,41 +1,9 @@ | ||||||||||||||
| # syntax=docker/dockerfile:1 | ||||||||||||||
| ############################################ | ||||||||||||||
| # Base runtime image | ||||||||||||||
| ############################################ | ||||||||||||||
| FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base | ||||||||||||||
| FROM mcr.microsoft.com/dotnet/aspnet:9.0 | ||||||||||||||
| WORKDIR /app | ||||||||||||||
| EXPOSE 8080 | ||||||||||||||
| ENV ASPNETCORE_URLS=http://+:8080 \ | ||||||||||||||
| DOTNET_EnableDiagnostics=0 | ||||||||||||||
| # Add DefaultConnection (empty by default; override at runtime) | ||||||||||||||
| # ENV | ||||||||||||||
| # ConnectionStrings__DefaultConnection="" | ||||||||||||||
| # Jwt__Key="" | ||||||||||||||
| # Jwt__AccessTokenExpiration="10" | ||||||||||||||
| # Jwt__RefreshTokenExpiration="7" | ||||||||||||||
| # Jwt__REFRESH_TOKEN_CLAIM_TYPE="RefreshToken" | ||||||||||||||
| # Jwt__REFRESH_TOKEN_EXPIRATION_CLAIM_TYPE="RefreshTokenExpiration" | ||||||||||||||
|
|
||||||||||||||
| ############################################ | ||||||||||||||
| # Build & publish | ||||||||||||||
| ############################################ | ||||||||||||||
| FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build | ||||||||||||||
| WORKDIR /src | ||||||||||||||
| COPY ["WebAPI/WebAPI.csproj", "./"] | ||||||||||||||
| RUN dotnet restore "WebAPI.csproj" | ||||||||||||||
| COPY . . | ||||||||||||||
| RUN dotnet build "WebAPI.csproj" -c Release -o /app/build | ||||||||||||||
| COPY publish/ . | ||||||||||||||
|
Comment on lines
+1
to
+7
|
||||||||||||||
|
|
||||||||||||||
|
||||||||||||||
| # Create a non-root user and switch to it | |
| RUN adduser --disabled-password --gecos '' appuser && \ | |
| chown -R appuser:appuser /app | |
| USER appuser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
cd WebAPIcommand in step 29 only affects that single step and doesn't persist to subsequent steps. Step 30'sls -alwill execute in the root directory, not in the WebAPI directory. Either combine these commands with&&or useworking-directoryparameter.