-
Notifications
You must be signed in to change notification settings - Fork 8
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
Slots Cleanup - Adding new check #1211
Merged
Merged
Changes from all commits
Commits
Show all changes
181 commits
Select commit
Hold shift + click to select a range
92e8df6
PR - Adding new check for checking PR and slots counts
amankumarrr 91a1e55
Adding Token-Id check
amankumarrr f63acfd
Adding link to actual repo and solving the query param
amankumarrr c4ec056
Removing --name from the query
amankumarrr e194d62
Checking variables
amankumarrr 9198f3b
Adding new step to load .env
amankumarrr f09db17
Removing quote from the resource group
amankumarrr d2d6999
Adding query to filter out the result
amankumarrr e5ef745
Adding check to compare the numbers
amankumarrr e13e756
Getting the PR ids
amankumarrr eb3891c
adding a step to check out
amankumarrr c784e2b
Adding count object with the PRs slots
amankumarrr 8ce4051
removing count from the extension
amankumarrr ceb355b
Wrapping the array inside the bracket
amankumarrr 6e1b01d
Updating counting logic
amankumarrr 508c8b9
adding tsv output for the slot name
amankumarrr c3e634f
Replacing the prefix of PR names
amankumarrr b04cc1e
Getting Slots ids to compare it with
amankumarrr f35d086
Adding logic to extract missing slots
amankumarrr 7ff559e
Adding comments for the step
amankumarrr 103db0b
Replacing the InputObject to SideIndicator to handle error
amankumarrr ccbf57b
Wrapping the object with double quote
amankumarrr f13ea4e
Logic to extract unique values
amankumarrr 75d55e9
Unique id from the object
amankumarrr 65e9656
Adding logic for the extraction of Slots ids
amankumarrr f360e60
wrapping the arrays in double quotes
amankumarrr 3b833bd
Fixing typo with variable name
amankumarrr 1aebc0a
Renaming variables
amankumarrr 27c4742
Adding scheduler for the action
amankumarrr 3c322a4
Adding workflow dispatcher
amankumarrr d8163b9
Adding workflow dispatch with the pull request
amankumarrr 52fb118
removing variable with dispatcher
amankumarrr d21a7d7
Modifying the delete flow and adding trigger for in the new flow
amankumarrr 15199df
Updating syntax
amankumarrr 1fa664e
wrapping the curl request with `
amankumarrr d0344b5
Curl - changing the syntax
amankumarrr abb326d
Adding third party action to trigger the workflow
amankumarrr 9c4db2c
Adding ref for the main branch
amankumarrr cb7c52b
adding the extention to find the yml
amankumarrr f3bfadf
Removing repo name since it's in same repo
amankumarrr 2b672b1
removing the input for the flow
amankumarrr 4b1402c
updating flow to callable flow and calling it from the flow itself
amankumarrr 8a32088
Converting the input into json
amankumarrr 0e6a2b3
adding the callable flow in separate action
amankumarrr 5a5ec91
Inheriting secrets
amankumarrr a33130b
Updating the slot logic
amankumarrr 5eca700
adding check to echo the array
amankumarrr cc19752
adding check for the second job
amankumarrr 84a3861
changing array to a single id
amankumarrr 6235f89
Clean up
amankumarrr 2ede1c3
Updating the variable name
amankumarrr e047cf9
displaying the variable
amankumarrr 4413e89
Adding firstSlotId
amankumarrr 187a709
Changing the logic to compare the PR slots
amankumarrr 0fc4689
fixing typo
amankumarrr e2280f2
Adding logic for single slot id
amankumarrr f7656d8
Slot id in an array
amankumarrr 028d5bc
Adding second check to avoid to avoid running second flow
amankumarrr f55e18b
Putting variable to outside of condition to update itself
amankumarrr 23b1a6e
Adding schedule to run the flow
amankumarrr 1b10738
fixing typo
amankumarrr f4dd28d
Adding logic to run it for multiple ids
amankumarrr 1457b0a
removing comment
amankumarrr 7bc1f4a
fixing the variable name
amankumarrr 0794bf0
adding json in the variable list
amankumarrr f0d5b86
spliting the input
amankumarrr 56a99e1
removing fromJSON to matrix
amankumarrr 59ee4ac
adding json
amankumarrr 2af222a
adding the comma and formatting it in Json
amankumarrr 35b2d43
adding the slotname in output
amankumarrr d16bac7
testing the object type
amankumarrr 7c06a76
setting up the variable name
amankumarrr c9e24d3
testing param
amankumarrr 30c1e74
removing hardcoded values
amankumarrr f7b3e33
testing with variable name
amankumarrr 9c9be79
changing the syntax for output
amankumarrr 41be2b1
changing into an array
amankumarrr 22ef157
changing the variable wrapping
amankumarrr 3a74afe
adding variable from json
amankumarrr 434fae4
putting into json
amankumarrr 3e7322e
Updating the param to JSON
amankumarrr 689b99d
wrapping the ouput
amankumarrr 09d0793
wrapping it with the object
amankumarrr 2e7203b
replacing double quotes with backslashes
amankumarrr 360bc65
fixing typo
amankumarrr 4ce7608
removing the second check
amankumarrr c0d2e3a
compressing the string
amankumarrr 6386964
removing already formatted json
amankumarrr 0659bc5
changing the variable name
amankumarrr a61be49
fixing variable name
amankumarrr bf3d92d
fixing the echo with json
amankumarrr 516f58b
adding string to convert the object
amankumarrr 259b3fa
removing the output thing
amankumarrr 578af7d
removing the step to add the string
amankumarrr 8838989
adding the matrix back
amankumarrr 21c4e75
adding the env
amankumarrr c2d3cbe
without env
amankumarrr 0d6eba9
adding the text
amankumarrr fbdbaa6
removing slot and parsing it first
amankumarrr 26cbccf
tesingt output
amankumarrr b5bb838
checking without env
amankumarrr e5a964d
with quotes
amankumarrr 1ee1257
adding the json string for testing
amankumarrr bf48b97
adding double quote
amankumarrr 10e78af
adding new formate
amankumarrr c5d3728
changing the type of input
amankumarrr 8602ed4
removing some more content
amankumarrr 850f246
without single quotes
amankumarrr 270105b
in double quotes
amankumarrr 271d498
changing the quotes
amankumarrr 600ecda
adding inside the object
amankumarrr 1026870
removing quotes
amankumarrr 7de303e
adding text
amankumarrr 52b1420
joining text
amankumarrr 198ccb8
adding json
amankumarrr ddae65f
without quote
amankumarrr c7e80f7
converting from json
amankumarrr 451c63c
adding space between comma's
amankumarrr 4688c55
using actual example
amankumarrr 29474c5
with env
amankumarrr a543c2b
adding new YML
amankumarrr aceebd6
assigning hardcoded values
amankumarrr 13bb549
adding hardcoded json
amankumarrr 4435931
single quote
amankumarrr d64fbae
adding formatted json
amankumarrr 09ea143
Json from the other workflow
amankumarrr f0a8c14
adding listofslotsFromFirst job
amankumarrr aa14592
adding json format
amankumarrr 3d42488
wrapping the text
amankumarrr e7335b1
Separating azure login
amankumarrr e346e92
Adding the dependencies for the different jobs
amankumarrr be513c2
reverting back last commit
amankumarrr f5384de
cleaning up the first flow
amankumarrr 651fe45
adding hardcoded false
amankumarrr 078a5b4
Clean up with the pr-close flow
amankumarrr 686ed51
making naming conventions consistent
amankumarrr e6a21e5
removing testing yml
amankumarrr ae962d3
handling single id scenario
amankumarrr 0391dd1
Clean up and check with single id
amankumarrr 948541a
Removing hardcoded values
amankumarrr bf13041
Clean with the naming conventions
amankumarrr dc189b8
Adding scheduling to run this flow
amankumarrr f8ee939
Merge branch 'main' into adding-new-check
amankumarrr 1cfae17
Update .github/workflows/check-active-prs-and-slots.yml
amankumarrr 40ba43e
Update .github/workflows/check-active-prs-and-slots.yml
amankumarrr 4dedf38
Update - camelCase for pr list step
amankumarrr 7913b03
Removing redundant steps
amankumarrr 9e13610
removing the quote to output the slots
amankumarrr 1358e59
echoing slot
amankumarrr c9b4acf
testing echo
amankumarrr 016ac99
Checking the length of the array
amankumarrr ba72b7e
Removing double quotes
amankumarrr 780551d
adding bool value to check the next step
amankumarrr 1353f62
updating logic for next flow
amankumarrr 3362dcf
using github cli
amankumarrr f8e56e0
adding github token as env
amankumarrr 8c09986
Adding hardcoded values
amankumarrr 2b98eb1
Adding hardcoded value to test
amankumarrr 8706bc5
Clean up the hardcoded values
amankumarrr f5a6428
Removing singular values
amankumarrr 97627e8
adding jq query to get the values
amankumarrr 0182c5b
Removing extra step and cleaning up the code for JSON
amankumarrr 79a6a08
test run for multiple ids
amankumarrr 99e3112
Clean up from hardcoded values
amankumarrr 9b8d3b4
testing json values
amankumarrr fe9da88
for testing
amankumarrr 1a64a23
testing it with JSOn
amankumarrr a4c446d
testing
amankumarrr 02d52c7
quoting it
amankumarrr b6ba3fa
adding the env. slot name
amankumarrr 50652d0
without outputting it
amankumarrr 6656036
Adding the values back
amankumarrr 7fa2c5d
removing from JSON
amankumarrr d603b08
adding an array for testing
amankumarrr 92501fc
testing
amankumarrr d52a64e
adding from json
amankumarrr 0650e3f
removing hardcoded values
amankumarrr ae3fc2b
Content - renaming the filename
amankumarrr 5b34818
Merge branch 'main' into adding-new-check
amankumarrr 81a709f
Update .github/workflows/slots-cleanup-weekly.yml
amankumarrr 17af89f
File - renaming it to make more sense
amankumarrr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,89 @@ | ||
name: Weekly app service slot cleanup | ||
|
||
on: | ||
schedule: | ||
# Monday at 12 PM UTC - https://cron.help/#0_12_*_*_MON | ||
- cron: "0 12 * * MON" | ||
workflow_dispatch: | ||
|
||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
|
||
defaults: | ||
run: | ||
shell: pwsh | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
check-pr-slots: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
slotsExistThatRequireDeletion: ${{ steps.comparision.outputs.slotsExistThatRequireDeletion }} | ||
|
||
steps: | ||
- name: Checking out | ||
uses: actions/checkout@v2 | ||
|
||
- name: Load .env file | ||
uses: xom9ikk/dotenv@v2 | ||
with: | ||
path: ./.github | ||
|
||
- name: Azure CLI - Login | ||
uses: azure/login@v1 | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
|
||
- name: Get list of deployed Slots | ||
id: slotList | ||
run: | | ||
$slots = $(az webapp deployment slot list ` | ||
--name ${{ env.APP_SERVICE_NAME }} ` | ||
--resource-group ${{env.AZURE_RESOURCE_GROUP }} ` | ||
--query '[].name' ` | ||
--output tsv | ` | ||
sed 's/pr-//g') | ||
echo "slots=$slots" >> $env:GITHUB_OUTPUT | ||
|
||
- name: Get list of active PRs | ||
id: prList | ||
run: | | ||
$active_prs=$(gh pr list --state open --json number | jq -r '.[].number') | ||
echo "active_prs=$active_prs" >> $env:GITHUB_OUTPUT | ||
|
||
- name: Compare PRs with Slots | ||
id: comparision | ||
run: | | ||
# Comparing the number of Slots and PRs | ||
$prList = "${{ steps.PRList.outputs.active_prs }}" -split ' ' | ||
$slotList = "${{ steps.slotList.outputs.slots }}" -split ' ' | ||
|
||
$slotsExistThatRequireDeletion = $slotList | Where-Object { $_ -notin $prList } | ||
$slotsNeedDeletion = $slotsExistThatRequireDeletion.Length -gt 0 | ||
|
||
if ( ! $slotsNeedDeletion ) { | ||
echo "✅ - Number of slots are equal to number of active PRs - 🏃 Skipping next step" | ||
} | ||
else { | ||
echo "❌ - Number of slots are not equal to number of active PRs" | ||
Write-Host "⚡- These slots need to be deleted : $slotsExistThatRequireDeletion" | ||
} | ||
echo "slotsExistThatRequireDeletion=$slotsExistThatRequireDeletion" >> $env:GITHUB_OUTPUT | ||
|
||
invokeDeleteSlot: | ||
name: Invoking PR Close/Delete | ||
needs: | ||
- check-pr-slots #Adding second check to avoid running this flow | ||
if: needs.check-pr-slots.outputs.slotsExistThatRequireDeletion != '' | ||
uses: ./.github/workflows/pr-close-delete-env.yml | ||
with: | ||
slotIDs: ${{ needs.check-pr-slots.outputs.slotsExistThatRequireDeletion }} | ||
permissions: | ||
id-token: write | ||
contents: read | ||
secrets: inherit |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Use a json serialized array instead of space delimited values. That way you can use fromJson on it when defining the matrix
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.
recommend json array and not space delimited (and apply to other slotIds param)