Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include in the Readme an example of how to use it in CI/CD Github action #45

Open
pcartas opened this issue Nov 9, 2022 · 1 comment

Comments

@pcartas
Copy link

pcartas commented Nov 9, 2022

Hi!
I been googleing how to show the html generated but i couldnt success ¿someone has an example of it used in a github action?
I tried with this but doesnt work:

name: Pull Request Staging

on:
  pull_request:
    branches:
      - staging

jobs:
  Terraform:
    name: Terraform Plan
    runs-on: ubuntu-latest
    steps:

    - name: Checkout Repo
      uses: actions/checkout@v2
    
    - name: Terraform Setup
      uses: hashicorp/setup-terraform@v1

    - name: Terraform Init
      run: cd ./staging; terraform init
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        TF_ACTION_WORKING_DIR: './staging'
        AWS_ACCESS_KEY_ID:  ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY:  ${{ secrets.AWS_SECRET_ACCESS_KEY }}

    - name: Terraform Validate
      run: terraform validate

    - name: Terraform Plan
      run: cd ./staging; terraform plan -out=plan.out; terraform show -json plan.out > plan.json
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        TF_ACTION_WORKING_DIR: './staging'
        AWS_ACCESS_KEY_ID:  ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY:  ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        
    - name: Terraform Visual Install
      run: cd staging; npm install -g @terraform-visual/cli
        
    - name: Generate the Report
      run: cd staging; terraform-visual --plan plan.json;
      
    - name: HTML preview
      id: html_preview
      uses: pavi2410/html-preview-action@v2
      with: 
        html_file: terraform-visual-report/index.html
      
@ipc-zpg
Copy link

ipc-zpg commented Nov 21, 2022

When you say this isn't working - can you expand on that?

I have noticed that your html_file is likely pointing to the wrong place, as you're not in the 'staging' directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants