Merge branch 'main' of https://github.com/TheSudoYT/terraform-provide… #20
This file contains hidden or 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
name: Update Documentation | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- '**' | |
permissions: | |
contents: write | |
jobs: | |
update_docs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: '1.22.2' | |
- name: Run go generate | |
run: go generate ./... | |
- name: Execute build_media_map script | |
id: script_output | |
run: | | |
chmod +x ./scripts/build_media_map.sh | |
echo "SCRIPT_OUTPUT<<EOF" >> $GITHUB_ENV | |
./scripts/build_media_map.sh >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Append output to docs/index.md | |
run: | | |
echo -e "\n# epic Provider\n$(cat docs/index.md)" > docs/index.md | |
echo "${{ env.SCRIPT_OUTPUT }}" >> docs/index.md | |
- name: Git push docs/index.md with media type and title mapping | |
run: | | |
git config --global user.name "${{ vars.TF_THESUDO_CI_COMMIT_AUTHOR }}" | |
git config --global user.email "${{ vars.TF_THESUDO_CI_COMMIT_EMAIL }}" | |
git add docs/index.md | |
git status | |
git diff-index --quiet HEAD || git commit -m "Update docs/index.md" | |
# Determine if this is a PR and extract branch name | |
if [[ "$GITHUB_REF" =~ pull\/([0-9]+)\/merge ]]; then | |
# Extract actual branch name for PRs | |
PR_NUMBER=${BASH_REMATCH[1]} | |
BRANCH_NAME=$(jq --raw-output .pull_request.head.ref $GITHUB_EVENT_PATH) | |
else | |
# Extract branch name from GITHUB_REF for normal pushes | |
BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
fi | |
git push origin HEAD:$BRANCH_NAME | |
env: | |
GITHUB_TOKEN: ${{ secrets.TF_THESUDO_COMMIT_GITHUB_TOKEN }} | |
#git push "https://${{ vars.TF_THESUDO_CI_COMMIT_AUTHOR }}:${{ secrets.TF_THESUDO_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" |