Switched to use azure login #1010
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
# Run daily and when custom data is updated to generate a new csv/json | |
name: update-microsoft-info | |
on: | |
# Triggers the workflow on push or pull request events but only for the "main" branch | |
push: | |
branches: [ "main" ] | |
paths-ignore: | |
- 'README.md' | |
- '_info/**' | |
pull_request: | |
branches: [ "main" ] | |
# Run twice a day (5.30am and 5.30pm) | |
schedule: | |
- cron: '30 5,17 * * *' | |
# Allows to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
permissions: | |
id-token: write | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v4 | |
- name: Set current date as env variable | |
run: echo "NOW=$(date +'%Y-%m-%d-T%H%M%S')" >> $GITHUB_ENV | |
- name: 'Az CLI login' | |
uses: azure/login@v2 | |
with: | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
allow-no-subscriptions: true | |
- name: Generate docs | |
uses: azure/powershell@v2 | |
with: | |
azPSVersion: "latest" | |
inlineScript: | | |
# Get Token | |
$token = az account get-access-token --resource-type ms-graph | |
# Connect to Microsoft Graph | |
$accessToken = ($token | ConvertFrom-Json).accessToken | ConvertTo-SecureString -AsPlainText -Force | |
Connect-MgGraph -AccessToken $accessToken | |
# Run export | |
./src/Export-MicrosoftApps.ps1 | |
./src/Export-GraphPermissions.ps1 | |
- name: Update repo | |
run: | | |
if [[ `git status --porcelain` ]]; then | |
# Changes | |
echo "Updating repo" | |
git config --global user.name 'Merill Fernando' | |
git config --global user.email 'merill@users.noreply.github.com' | |
git commit -am "Daily automation" | |
git push | |
else | |
# No changes | |
echo "No changes" | |
fi |