-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
7 additions
and
9 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,29 +52,27 @@ stages: | |
chmod +x /tmp/terraform-docs | ||
displayName: 'Download terraform-docs' | ||
- script: | | ||
# Variables | ||
github_token="$(GITHUB_TOKEN)" | ||
# Generate or update README.md | ||
/tmp/terraform-docs markdown table . > README.md | ||
# Check if README.md has been updated or created and add to PR | ||
if [ -f README.md ]; then | ||
echo "README.md file generated/updated." | ||
git config --global user.email "[email protected]" | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "DevOps Bot" | ||
git add README.md | ||
git commit -m "Update README.md with module documentation" | ||
# Set remote URL with authentication token | ||
git remote set-url origin https://$(GITHUB_TOKEN)@github.com/Think-Cube/terraform-azure-route-table.git | ||
git remote set-url origin https://$(GITHUB_TOKEN)@github.com/$(GITHUB_REPO).git | ||
# Pull the latest changes to avoid conflicts (source branch of the PR) | ||
git pull origin $(System.PullRequest.SourceBranch) --rebase | ||
git pull origin '$(System.PullRequest.SourceBranch)' --rebase || exit 1 | ||
# Push changes | ||
git push origin HEAD:$(System.PullRequest.SourceBranch) | ||
git push origin HEAD:'$(System.PullRequest.SourceBranch)' || exit 1 | ||
else | ||
echo "Failed to generate README.md" | ||
exit 1 | ||
echo "No changes in README.md detected." | ||
fi | ||
displayName: 'Generate and Update README.md Documentation' |