Skip to content

Auto PR: Regenerating the Go SDK (d7751abf0a058189ea90226f585ae6dfe3e5707c) #675

Auto PR: Regenerating the Go SDK (d7751abf0a058189ea90226f585ae6dfe3e5707c)

Auto PR: Regenerating the Go SDK (d7751abf0a058189ea90226f585ae6dfe3e5707c) #675

name: Conditionally Release the SDK
on:
pull_request:
types: ['closed']
concurrency:
group: 'release-${{ github.head_ref }}'
cancel-in-progress: true
jobs:
release-go-sdk:
if: ${{ github.event.pull_request.merged == true && contains( github.event.pull_request.labels.*.name, 'release-once-merged') }}
runs-on: custom-linux-medium
permissions:
contents: write
outputs:
latest_tag: ${{ steps.results.outputs.latest_tag }}
should_update_azurerm: ${{ steps.results.outputs.should_update_azurerm }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: run the unit tests
run: |
make tools
make test
- name: "determine and publish the Git Tag"
run: |
./scripts/determine-and-publish-git-tag.sh
- id: results
name: "collecting outputs"
run: |
latestTag=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "latest_tag=$latestTag" >> "$GITHUB_OUTPUT"
echo "should_update_azurerm=${{ github.event.pull_request.merged == true && contains( github.event.pull_request.labels.*.name, 'update-azurerm-after-release') }}" >> "$GITHUB_OUTPUT"
shell: bash
conditionally-update-azurerm:
needs: [release-go-sdk]
if: ${{github.event.pull_request.merged == true && contains( github.event.pull_request.labels.*.name, 'update-azurerm-after-release') }}
runs-on: custom-linux-xl
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: ./.go-version
- name: "Launch SSH Agent"
run: |
# launch an ssh agent and export it's env vars
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
env:
SSH_AUTH_SOCK: /tmp/azurerm_ssh_agent.sock
- name: "Load SSH Key"
run: |
# load the Deployment Write Key for the AzureRM repository
echo "${{ secrets.AZURERM_DEPLOYMENT_WRITE_KEY }}" | ssh-add -
env:
SSH_AUTH_SOCK: /tmp/azurerm_ssh_agent.sock
- id: update-azurerm-provider
name: "Update then push the AzureRM Provider"
run: |
./scripts/update-azurerm-provider.sh ${{ needs.release-go-sdk.outputs.latest_tag }}
if [[ $(git diff main --name-only | wc -l) -gt 0 ]]; then
echo "has_changes_to_push=true" >> "$GITHUB_OUTPUT"
else
echo "has_changes_to_push=false" >> "$GITHUB_OUTPUT"
fi
shell: bash
env:
GIT_COMMIT_USERNAME: "hc-github-team-tf-azure"
RUNNING_IN_AUTOMATION: "yep"
SSH_AUTH_SOCK: /tmp/azurerm_ssh_agent.sock
- name: "Remove the Key from the SSH Agent"
if: always()
run: |
# remove the ssh key
ssh-add -D
env:
SSH_AUTH_SOCK: /tmp/azurerm_ssh_agent.sock
- name: "Terminate the SSH Agent"
if: always()
run: |
pkill -9 ssh-agent
- name: Wait 60s for the other Github Action to open the PR
if: success()
run: |
echo "Sleeping 60s to give Github time to create the PR.."
sleep 60
- id: find-pr-number
name: Find the PR number
if: ${{ steps.update-azurerm-provider.outputs.has_changes_to_push == 'true' }}
uses: nick-fields/retry@14672906e672a08bd6eeb15720e9ed3ce869cdd4 # v2.9.0
with:
max_attempts: 20
polling_interval_seconds: 15
retry_on: any
shell: bash
timeout_seconds: 30
command: |
echo "Finding the PR number.."
pr_number=$(gh pr list --repo="hashicorp/terraform-provider-azurerm" --search "author:hc-github-team-tf-azure sort:created-desc is:pr is:open" --json "headRefName,number" | jq '.[] | select(.headRefName=="auto-deps-pr/updating-go-azure-sdk-to-${{ needs.release-go-sdk.outputs.latest_tag }}") | .number')
if [[ "${pr_number}" == "" ]]; then
# not ready yet
echo "PR Number not found, not available yet?"
exit 1
fi
echo "PR Number was ${pr_number}"
echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: "${{ secrets.AZURERM_COMMENT_KEY }}"
- name: Comment on the PR with the PR description
if: ${{ steps.update-azurerm-provider.outputs.has_changes_to_push == 'true' }}
run: |
pr_number="${{ steps.find-pr-number.outputs.pr_number }}"
echo "Commenting on PR Number ${pr_number}.."
gh issue comment $pr_number --repo "hashicorp/terraform-provider-azurerm" --body-file ./tmp/pr-description.txt
shell: bash
env:
GH_TOKEN: "${{ secrets.AZURERM_COMMENT_KEY }}"