Skip to content

Commit fd6168f

Browse files
authored
Merge pull request #84 from joelbyford/dependabot-fix
Adding on pull_request_target workflow
2 parents 08d8aa5 + 930e7c7 commit fd6168f

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Test on Pull Request to Main
2+
3+
on:
4+
pull_request_target:
5+
branches: [ main ]
6+
7+
permissions:
8+
id-token: write
9+
contents: read
10+
11+
jobs:
12+
build:
13+
name: Build To Dev Slot
14+
runs-on: ubuntu-latest
15+
# Ensure that the job runs only when the PR is opened by dependabot
16+
if: ${{ github.actor == 'dependabot[bot]' }}
17+
steps:
18+
- name: Git checkout
19+
uses: actions/checkout@v2
20+
21+
# Installs the CLI-beta in a python venv
22+
- name: Installing CLI-beta for OpenID Connect
23+
run: |
24+
cd ../..
25+
CWD="$(pwd)"
26+
python3 -m venv oidc-venv
27+
. oidc-venv/bin/activate
28+
echo "activated environment"
29+
python3 -m pip install -q --upgrade pip
30+
echo "started installing cli beta"
31+
pip install -q --extra-index-url https://azcliprod.blob.core.windows.net/beta/simple/ azure-cli
32+
echo "***************installed cli beta*******************"
33+
echo "$CWD/oidc-venv/bin" >> $GITHUB_PATH
34+
35+
# Logs into Azure via OIDC (note no password)
36+
- name: 'Az OIDC CLI login'
37+
uses: azure/[email protected]
38+
with:
39+
client-id: ${{ secrets.AZURE_CLIENTID }}
40+
tenant-id: ${{ secrets.AZURE_TENANTID }}
41+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTIONID }}
42+
# Name of the environment. Supported values are azurecloud, azurestack, azureusgovernment, azurechinacloud, azuregermancloud. Default being azurecloud
43+
# environment: azurecloud
44+
45+
- name: Setup dotnet 6.0.x
46+
uses: actions/setup-dotnet@v1
47+
with:
48+
dotnet-version: 6.0.x
49+
50+
- name: Restore package dependencies
51+
run: dotnet restore
52+
53+
- name: dotet build
54+
run: dotnet build --no-restore --configuration Release
55+
56+
- name: dotnet publish
57+
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
58+
59+
- name: zip package
60+
run: |
61+
cd ${{env.DOTNET_ROOT}}/myapp
62+
zip -r myapp.zip .
63+
64+
- name: Azure CLI Publish
65+
run: az webapp deployment source config-zip -g rgDoNotDeleteDemos -n ${{secrets.APP_NAME}} --slot test --src ${{env.DOTNET_ROOT}}/myapp/myapp.zip
66+
67+
test:
68+
name: Smoke Test Dev Slot
69+
runs-on: ubuntu-latest
70+
needs: build
71+
# Ensure that the job runs only when the PR is opened by dependabot
72+
if: ${{ github.actor == 'dependabot[bot]' }}
73+
steps:
74+
- name: Git checkout
75+
uses: actions/checkout@v2
76+
77+
- name: Setup Python
78+
uses: actions/[email protected]
79+
80+
- name: Install pytest
81+
run: |
82+
python -m pip install --upgrade pip
83+
pip install pytest
84+
pip install requests
85+
86+
- name: Test with pytest
87+
run: |
88+
cd QrCodeApiApp/test
89+
pytest --url ${{secrets.TEST_URL}}
90+
91+
92+
93+
94+

0 commit comments

Comments
 (0)