From abaa51f1228587f798b56fb006120989da8b5618 Mon Sep 17 00:00:00 2001 From: neha_gupta Date: Fri, 5 May 2023 13:46:51 +0530 Subject: [PATCH] common job to choose m365 account (#3288) Its a prerequisite for https://github.com/alcionai/corso/pull/3287 A common job which helps choosing m365 account using Round Robin. #### Does this PR need a docs update or release note? - [ ] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [x] :no_entry: No #### Type of change - [ ] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [x] :robot: Supportability/Tests - [ ] :computer: CI/Deployment - [ ] :broom: Tech Debt/Cleanup #### Issue(s) * # #### Test Plan - [x] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- .github/workflows/accSelector.yaml | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/accSelector.yaml diff --git a/.github/workflows/accSelector.yaml b/.github/workflows/accSelector.yaml new file mode 100644 index 000000000..2340d2427 --- /dev/null +++ b/.github/workflows/accSelector.yaml @@ -0,0 +1,46 @@ +name: SetM365AppAcc + +on: + workflow_call: + outputs: + client_app_slot: + value: ${{ jobs.GetM365App.outputs.client_app_slot }} + client_id_env: + value: ${{ jobs.GetM365App.outputs.client_id_env }} + client_secret_env: + value: ${{ jobs.GetM365App.outputs.client_secret_env }} + +jobs: + GetM365App: + environment: Testing + runs-on: ubuntu-latest + outputs: + client_app_slot: ${{ steps.roundrobin.outputs.CLIENT_APP_SLOT }} + client_id_env: ${{ steps.roundrobin.outputs.CLIENT_ID_ENV }} + client_secret_env: ${{ steps.roundrobin.outputs.CLIENT_SECRET_ENV }} + steps: + - name: Figure out which client id to use + id: roundrobin + run: | + slot=$((GITHUB_RUN_NUMBER % 4)) + echo "CLIENT_APP_SLOT=$slot" >> $GITHUB_OUTPUT + + case $slot in + + 0) + echo "CLIENT_ID_ENV=CLIENT_ID" >> $GITHUB_OUTPUT + echo "CLIENT_SECRET_ENV=CLIENT_SECRET" >> $GITHUB_OUTPUT + ;; + 1) + echo "CLIENT_ID_ENV=CLIENT_ID_2" >> $GITHUB_OUTPUT + echo "CLIENT_SECRET_ENV=CLIENT_SECRET_2" >> $GITHUB_OUTPUT + ;; + 2) + echo "CLIENT_ID_ENV=CLIENT_ID_3" >> $GITHUB_OUTPUT + echo "CLIENT_SECRET_ENV=CLIENT_SECRET_3" >> $GITHUB_OUTPUT + ;; + 3) + echo "CLIENT_ID_ENV=CLIENT_ID_4" >> $GITHUB_OUTPUT + echo "CLIENT_SECRET_ENV=CLIENT_SECRET_4" >> $GITHUB_OUTPUT + ;; + esac \ No newline at end of file