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

Reuse downloaded terraform version between multiple actions #30

Closed
donovanmuller opened this issue Jan 14, 2021 · 2 comments
Closed

Reuse downloaded terraform version between multiple actions #30

donovanmuller opened this issue Jan 14, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@donovanmuller
Copy link

If you combo multiple actions together in a single job, the Terraform version is downloaded for every action. It would be beneficial to share the same Terraform version between actions. I.e. The first action downloads terraform if the binary doesn't exist and the same version is reused in subsequent actions.

E.g. workflow

...
jobs:
  cluster:
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Get branch name
        uses: nelonoel/branch-name@v1.0.1

      - name: Use branch workspace
        uses: dflook/terraform-new-workspace@v1
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        with:
          path: blah
          workspace: ${{ env.BRANCH_NAME }}

      - name: Create cluster
        uses: dflook/terraform-apply@v1
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        with:
          workspace: ${{ env.BRANCH_NAME }}
          path: blah
          auto_approve: true

results in two downloads:

Run dflook/terraform-new-workspace@v1
...

Reading latest terraform version
Downloading https://releases.hashicorp.com/terraform/0.14.4/terraform_0.14.4_linux_amd64.zip to terraform_0.14.4_linux_amd64.zip
Downloading ...
33518568 bytes downloaded.
Switched terraform to version "0.14.4" 

...

Run dflook/terraform-apply@v1
...

Reading latest terraform version
Downloading https://releases.hashicorp.com/terraform/0.14.4/terraform_0.14.4_linux_amd64.zip to terraform_0.14.4_linux_amd64.zip
Downloading ...
33518568 bytes downloaded.
Switched terraform to version "0.14.4" 
@dflook
Copy link
Owner

dflook commented Jan 14, 2021

Hi @donovanmuller, thanks for creating an issue. This is a good idea.

@dflook dflook added the enhancement New feature or request label Jan 14, 2021
@dflook
Copy link
Owner

dflook commented Jan 16, 2021

Release v1.5.2 will only download the terraform binary once per job, if required. The terraform version included in the image has also been updated to 0.14.4.

@dflook dflook closed this as completed Jan 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants