-
Notifications
You must be signed in to change notification settings - Fork 100
Reuse deployment steps #64
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
base: main
Are you sure you want to change the base?
Changes from all commits
5e94794
af9eceb
a1b6472
db8d071
fdf3bbb
b905028
dbec7b5
dad6796
e2b3003
acefad0
25a88c8
b87775f
aa080ee
7fb37c9
3fae991
420c51e
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,65 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| name: ci | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up .NET Core | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: 9.0 | ||
|
|
||
| # Did not include a dotnet build step because imn the test, we are going to build anyway. We did not use the "--no-build" flag. | ||
| # Also, We have the test runiing imn another workflo, but this is so critical that we included this here again even if someone | ||
| # bypasses the ruleset, we will have these test here anyway. | ||
|
|
||
| - name: dotnet test | ||
| run: dotnet test --configuration Release | ||
|
|
||
| # I did not include a step for dotnet format because we already took care of that indirectly for this repo. We enforced rules to | ||
| # have the incomming branch to be updated with the branch "main" changes. Also, as status checks are required and we have other | ||
| # workflow thayt takes care of that, there is no need to include formatting here. | ||
|
|
||
| # Of course, the recommendation is to have ALL verifications in the CI workflow | ||
|
|
||
| - name: dotnet publish | ||
| run: dotnet publish src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj --configuration Release -o artifacts-release-folder | ||
|
|
||
| - name: upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: dometrain-artifact | ||
| path: artifacts-release-folder/ | ||
|
|
||
| deploy-dev: | ||
| name: Deploy Dev | ||
| needs: build # We make sure this job waits for the "build" job | ||
| uses: ./.github/workflows/deploy-to-azure.yml | ||
| with: | ||
| env: prod | ||
| secrets: inherit | ||
|
|
||
|
|
||
| deploy-prod: | ||
| name: Deploy Pro | ||
| needs: deploy-dev | ||
| uses: ./.github/workflows/deploy-to-azure.yml | ||
| with: | ||
| env: prod | ||
| secrets: inherit | ||
|
|
||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| name: Deploy to azure | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| env: | ||
| required: true | ||
| type: string | ||
| secrets: | ||
| AZURE_CLIENT_ID: | ||
| required: true | ||
| AZURE_TENANT_ID: | ||
| required: true | ||
| AZURE_SUBSCRIPTION_ID: | ||
| required: true | ||
| jobs: | ||
| deploy: | ||
| name: Deploy ${{ inputs.env }} | ||
| runs-on: ubuntu-latest | ||
| environment: ${{ inputs.env }} | ||
|
|
||
| steps: | ||
| - name: download artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: dometrain-artifact | ||
| path: artifacts/ | ||
|
|
||
| - name: Azure login | ||
| uses: azure/login@v2 | ||
| with: | ||
| client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
| tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
| subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
|
|
||
| - name: 'Deploy to Azure App Service Name' | ||
| uses: azure/webapps-deploy@v2 | ||
Check warningCode scanning / CodeQL Unpinned tag for a non-immutable Action in workflow
Unpinned 3rd party Action 'Deploy to azure' step [Uses Step](1) uses 'azure/webapps-deploy' with ref 'v2', not a pinned commit hash
|
||
| with: | ||
| app-name: app-dometrain-github-actions-fgavilan-${{ inputs.env }} | ||
| package: artifacts/ | ||
|
Comment on lines
+18
to
+40
Check warningCode scanning / CodeQL Workflow does not contain permissions
Actions Job or Workflow does not set permissions
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| name: PR Verify | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ "main" ] | ||
|
|
||
| jobs: | ||
| build: | ||
| name: PR Verify | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up .NET Core | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: 9.0 | ||
|
|
||
| - name: Build with dotnet | ||
| run: dotnet build --configuration Release | ||
|
|
||
| - name: dotnet test | ||
| run: dotnet test --configuration Release --no-build | ||
|
|
||
| - name: dotnet format | ||
| run: dotnet format -v detailed --verify-no-changes | ||
|
Comment on lines
+9
to
+28
Check warningCode scanning / CodeQL Workflow does not contain permissions
Actions Job or Workflow does not set permissions
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: Print Variable Values | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| SOME_VALUE: Francisco | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Print | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Print using runner's shell specific syntax | ||
| run: echo "the value of SOME_VALUE is $SOME_VALUE" | ||
|
|
||
| - name: Print using Context | ||
| run: echo "Again, the value of SOME_VALUE is ${{env.SOME_VALUE}}". | ||
|
|
||
|
Comment on lines
+11
to
+20
Check warningCode scanning / CodeQL Workflow does not contain permissions
Actions Job or Workflow does not set permissions
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| // Use IntelliSense to learn about possible attributes. | ||
| // Hover to view descriptions of existing attributes. | ||
| // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| { | ||
| "type": "chrome", | ||
| "request": "launch", | ||
| "name": "Launch Chrome against localhost", | ||
| "url": "http://localhost:8080", | ||
| "webRoot": "${workspaceFolder}" | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "sdk": { | ||
| "version": "8.0.0", | ||
| "version": "9.0.0", | ||
| "rollForward": "latestMinor", | ||
| "allowPrerelease": false | ||
| } | ||
|
|
||
Check warning
Code scanning / CodeQL
Unpinned tag for a non-immutable Action in workflow