Open charmingnewt opened 2 years ago
In the meantime, I've worked around the issue with the following configuration:
name: Terraform Docs
on:
workflow_call:
secrets:
terraformdocs:
description: 'A token passed from the caller workflow'
required: true
jobs:
docs:
name: Terraform Docs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
# This PAT is required so the resulting docs push will trigger an additional workflow run.
token: ${{ secrets.terraformdocs }}
- name: Record latest author
run: |
echo "ORIGINAL_COMMIT_AUTHOR=$(git log -1 --pretty=format:'%ae')" >> "$GITHUB_ENV"
- name: Terraform Docs
uses: terraform-docs/gh-actions@v1.0.0
with:
git-push: "true"
git-commit-message: "Terraform Docs Automated Update"
git-push-user-email: "terraform-docs-bot@example.com"
git-push-user-name: "terraform-docs-bot-${{ env.GITHUB_ACTOR }}"
- name: Check for changes
run: |
if [[ "$(git log -1 --pretty=format:'%ae')" != "${ORIGINAL_COMMIT_AUTHOR}" ]]
then
echo "Changes detected. Failing workflow now to prevent duplicate subsequent steps."
exit 1
fi
What problem are you facing?
I am currently using terraform-docs within a larger workflow on pull requests. Because I am using the
git-push
feature, I would like to have terraform-docs be the first job executed, and only execute subsequent jobs if there is NO push from the terraform-docs job. In order to do this, I need to use both thegit-push
andfail-on-diff
options..github/workflows/pull_request.yml
.github/workflows/terraform-docs.yml
How could terraform-docs help solve your problem?
I am more than happy to PR if there is appetite from the community for the change. It seems the current logic is:
and the desired logic would be something like:
Thanks for your time.