Open arivictor opened 9 months ago
I've also attempted to manually install terraform docs: workflow
jobs:
docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Check README.md is up to date
run: |
curl -Lo ./terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/v0.17.0/terraform-docs-v0.17.0-linux-amd64.tar.gz
tar -xzf terraform-docs.tar.gz
chmod +x terraform-docs
./terraform-docs . --output-check
output
Run curl -Lo ./terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/v0.17.0/terraform-docs-v0.17.0-linux-amd64.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 6014k 100 6014k 0 0 19.7M 0 --:--:-- --:--:-- --:--:-- 19.7M
Error: README.md is out of date
Error: Process completed with exit code 1.
But when I run it locally
» terraform-docs . --output-check
README.md is up to date
I'm not sure what the remote is picking up that's causing a difference...
I saved the results the remote is giving me and then did a diff with my local copy:
diff README.md README2.md
< | <a name="provider_google"></a> [google](#provider_google) | 4.84.0 |
< | <a name="provider_google-beta"></a> [google-beta](#provider_google-beta) | 4.84.0 |
---
> | <a name="provider_google"></a> [google](#provider_google) | < 5.0 |
> | <a name="provider_google-beta"></a> [google-beta](#provider_google-beta) | < 5.0 |
🤔 why
AHA!
if I run terraform-docs
without initialising terraform terraform init
it takes the exact provider version from my terraform. If I initialise first, it uses whatever it downloads which happened to be 4.84.0
.
So locally I had initialised, but remotely its just running terraform-docs as is.
Was running into the same issue. Ran terraform-docs
locally but the github actions was failing with the same Error: Uncommitted change(s) has been found!
error.
Because I hadn't committed .terraform-lock.hcl
, it wasn't present in GHA and so it uses provider version constraints from the required_providers
block, compared to locally where it would use the exact version from .terraform.lock.hcl
.
Running rm -r .terraform/ .terraform.lock.hcl
locally and then re-running terraform-docs
fixed the issue and allowed the README generated locally match what gets generated in GHA.
Thanks @arivictor for the fix 🫡
Describe the bug
I am trying to do a
fail-on-diff
check for a terraform module doc on a pull request. The GHA fails withThere is no change between my current README.md and the generated one (well, there shouldn't be in theory).
How can we reproduce it?
workflow
config
Environment information