Skip to content
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

move pre cleanup to main and add pre-if and post-if #484

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

YanaXu
Copy link
Collaborator

@YanaXu YanaXu commented Sep 13, 2024

This PR is going to fix #426.

What are in this PR

  • Remove pre step from Azure Login Action and add the "pre cleanup" to main step.
  • Add an env variable AZURE_LOGIN_PRE_CLEANUP for checking if "cleanup before login" is necessary. By default, "cleanup before login" is disabled, only when AZURE_LOGIN_PRE_CLEANUP is set and is "true", "cleanup before login" will be run.
  • Add an env variable AZURE_LOGIN_POST_CLEANUP for checking if "post cleanup" is necessary. By default, "post cleanup" is enabled.

Description of the issues we know about

1. If Azure CLI, PowerShell or Azure PowerShell are not pre-installed on runner but installed in the steps of the workflow, an warning will be thrown in the pre step. E.g., "ephemeral self-hosted runners" as metioned in #426.
  • It'll be fixed in this PR since pre step will be removed.
2. pre cleanup or post cleanup are not necessary for GitHub-hosted runners since they are always clean.
  • After this PR, by default, there is no pre cleanup in a job.
  • post cleanup does no harm. But it's also OK if users set env AZURE_LOGIN_POST_CLEANUP to false to skip post cleanup in case of GitHub-hosted runners.
3. If Azure Login Action runs multiple times in a job, there will be multiple pre and post steps.
  • After this PR, there are no pre steps.
  • Multiple post cleanup steps are not necessary. Users can set env AZURE_LOGIN_POST_CLEANUP to true for only one Azure Login Action step and set env AZURE_LOGIN_POST_CLEANUP to false for all other Azure Login Action steps.
4. If there is a if in Azure Login Action and it doesn't match, Azure Login Action will be skipped but the pre step will still run.
  • It'll be fixed in this PR since pre step will be removed.
5. Composite Action does not support pre step and will throw an warning.
  • It'll be fixed in this PR since pre step will be removed.
  • post step will work well.
6. Local Action (checkout the aciton and run it) does not support pre step and will throw an warning.
  • It'll be fixed in this PR since pre step will be removed.
  • post step will work well.

Reference

How to use

    - name: Azure Login
      uses: azure/login@v2
      env:
        AZURE_LOGIN_PRE_CLEANUP: false
        AZURE_LOGIN_POST_CLEANUP: false
      with:
        client-id: ${{ secrets.CLIENT_ID }}
        tenant-id: ${{ secrets.TENANT_ID }}
        subscription-id: ${{ secrets.SUBSCRIPTION_ID }}
        enable-AzPSSession: true

@YanaXu YanaXu merged commit 73ceb51 into Azure:master Sep 14, 2024
7 checks passed
@YanaXu YanaXu deleted the yanxu/remove_pre branch September 14, 2024 05:28
@HowardvanRooijen
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make pre and post action cleanup (az account clear) optional for better performance on ephemeral runners
3 participants