-
Notifications
You must be signed in to change notification settings - Fork 0
add reusable workflow #18
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,76 @@ | |||||||||||||||||||||||||||||
| name: CI | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| on: | |||||||||||||||||||||||||||||
| push: | |||||||||||||||||||||||||||||
| branches: [ "main" ] | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| jobs: | |||||||||||||||||||||||||||||
| build: | |||||||||||||||||||||||||||||
| name: CI | |||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| steps: | |||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 # Check out the repository first | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| # The other verification steps (checkout, build, format, etc.) will be run from PR Verify workflow already | |||||||||||||||||||||||||||||
| - name: Dotnet test | |||||||||||||||||||||||||||||
| run: dotnet test src/GitHubActionsDotNet.Api.Tests/GitHubActionsDotNet.Api.Tests.csproj --configuration Release | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Dotnet publish | |||||||||||||||||||||||||||||
| run: dotnet publish src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj --configuration Release -o artifacts | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - uses: actions/upload-artifact@v4 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| name: domtrain-artifacts | |||||||||||||||||||||||||||||
| path: artifacts/ | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| deploy_dev: | |||||||||||||||||||||||||||||
| name: Deploy Dev | |||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||||||||
| needs: build # By default jobs runs in parallel, this makes sure deploy runs after build | |||||||||||||||||||||||||||||
| environment: dev | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| steps: | |||||||||||||||||||||||||||||
| - uses: actions/download-artifact@v4 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| name: domtrain-artifacts #The name "domtrain-artifacts" is what makes teh link between the upload and download steps | |||||||||||||||||||||||||||||
| 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 }} | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| # Deploy to Azure Web apps | |||||||||||||||||||||||||||||
| - name: 'Deploy to Azure App Service' | |||||||||||||||||||||||||||||
| uses: azure/webapps-deploy@v2 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name, i.e. app-domtrain-github-scottsauber-dev | |||||||||||||||||||||||||||||
| package: artifacts/ | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| deploy_prod: | |||||||||||||||||||||||||||||
|
Comment on lines
+28
to
+53
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
Copilot AutofixAI about 1 month ago In general, the fix is to explicitly declare a The best minimal fix without changing functionality is:
Concretely, in permissions:
contents: readNo imports or additional definitions are needed, as this is purely a YAML workflow configuration change.
Suggested changeset
1
.github/workflows/ci-with-step.yml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
|||||||||||||||||||||||||||||
| name: Deploy Prod | |||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||||||||
| needs: deploy_dev # By default jobs runs in parallel, this makes sure deploy prod runs after deploy dev | |||||||||||||||||||||||||||||
| environment: prod | |||||||||||||||||||||||||||||
| steps: | |||||||||||||||||||||||||||||
| - uses: actions/download-artifact@v4 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| name: domtrain-artifacts #The name "domtrain-artifacts" is what makes teh link between the upload and download steps | |||||||||||||||||||||||||||||
| 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 }} | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| # Deploy to Azure Web apps | |||||||||||||||||||||||||||||
| - name: 'Deploy to Azure App Service' | |||||||||||||||||||||||||||||
| uses: azure/webapps-deploy@v2 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name, i.e. app-domtrain-github-scottsauber-prod | |||||||||||||||||||||||||||||
| package: artifacts/ | |||||||||||||||||||||||||||||
|
Comment on lines
+54
to
+76
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
Copilot AutofixAI about 1 month ago In general, the fix is to add an explicit The single best minimal fix here is to add a Concretely: edit
Suggested changeset
1
.github/workflows/ci-with-step.yml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
|||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,50 +1,51 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
|
|
||
| jobs: | ||
| build: | ||
| name: CI | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 # Check out the repository first | ||
|
|
||
| # The other verification steps (checkout, build, format, etc.) will be run from PR Verify workflow already | ||
| - name: Dotnet test | ||
| run: dotnet test src/GitHubActionsDotNet.Api.Tests/GitHubActionsDotNet.Api.Tests.csproj --configuration Release | ||
|
|
||
| - name: Dotnet publish | ||
| run: dotnet publish src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj --configuration Release -o artifacts | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: domtrain-artifacts | ||
| path: artifacts/ | ||
|
|
||
| deploy_dev: | ||
| name: Deploy Dev | ||
| runs-on: ubuntu-latest | ||
| needs: build # By default jobs runs in parallel, this makes sure deploy runs after build | ||
|
|
||
| steps: | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| name: domtrain-artifacts #The name "domtrain-artifacts" is what makes teh link between the upload and download steps | ||
| path: artifacts/ | ||
| # name: CI | ||
|
|
||
| # on: | ||
| # push: | ||
| # branches: [ "main" ] | ||
|
|
||
| # jobs: | ||
| # build: | ||
| # name: CI | ||
| # runs-on: ubuntu-latest | ||
|
|
||
| # steps: | ||
| # - uses: actions/checkout@v4 # Check out the repository first | ||
|
|
||
| # # The other verification steps (checkout, build, format, etc.) will be run from PR Verify workflow already | ||
| # - name: Dotnet test | ||
| # run: dotnet test src/GitHubActionsDotNet.Api.Tests/GitHubActionsDotNet.Api.Tests.csproj --configuration Release | ||
|
|
||
| # - name: Dotnet publish | ||
| # run: dotnet publish src/GitHubActionsDotNet.Api/GitHubActionsDotNet.Api.csproj --configuration Release -o artifacts | ||
|
|
||
| # - uses: actions/upload-artifact@v4 | ||
| # with: | ||
| # name: domtrain-artifacts | ||
| # path: artifacts/ | ||
|
|
||
| # deploy_dev: | ||
| # name: Deploy Dev | ||
| # runs-on: ubuntu-latest | ||
| # needs: build # By default jobs runs in parallel, this makes sure deploy runs after build | ||
|
|
||
| # steps: | ||
| # - uses: actions/download-artifact@v4 | ||
| # with: | ||
| # name: domtrain-artifacts #The name "domtrain-artifacts" is what makes teh link between the upload and download steps | ||
| # 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 }} | ||
| # # Login to Azure | ||
| # - 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 }} | ||
|
|
||
| # Deploy to Azure Web apps | ||
| - name: 'Deploy to Azure App Service' | ||
| uses: azure/webapps-deploy@v2 | ||
| with: | ||
| app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name, i.e. app-domtrain-github-scottsauber-dev | ||
| package: artifacts/ | ||
| # # Deploy to Azure Web apps | ||
| # - name: 'Deploy to Azure App Service' | ||
| # uses: azure/webapps-deploy@v2 | ||
| # with: | ||
| # app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name, i.e. app-domtrain-github-scottsauber-dev | ||
| # package: artifacts/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| name: "Step Deploy" | ||
|
|
||
| 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 to ${{ inputs.env }} | ||
| runs-on: ubuntu-latest | ||
| environment: ${{ inputs.env }} | ||
|
|
||
| steps: | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| name: domtrain-artifacts #The name "domtrain-artifacts" is what makes teh link between the upload and download steps | ||
| path: artifacts/ | ||
|
|
||
| # Login to Azure | ||
| - 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 }} | ||
|
|
||
| # Deploy to Azure Web apps | ||
| - name: 'Deploy to Azure App Service' | ||
| uses: azure/webapps-deploy@v2 | ||
| with: | ||
| app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name, i.e. app-domtrain-github-scottsauber-dev | ||
| package: artifacts/ |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI about 1 month ago
To fix the problem, explicitly declare a
permissionsblock so that theGITHUB_TOKENused in this workflow has only the minimal rights it needs. Since none of the jobs perform operations that modify the repository (such as pushing commits, creating releases, or managing issues/PRs), the minimal and sufficient permission iscontents: read. Placing thispermissionsblock at the root of the workflow ensures it applies to all jobs unless they override it.Concretely, in
.github/workflows/ci-with-step.yml, add a top-levelpermissions:section right under thename: CIline (beforeon:). The block should read:No changes are needed inside the individual jobs. No additional imports or actions are required; this change only adjusts the workflow’s static YAML configuration and does not alter the functional behavior of the build and deployments.