├── .editorconfig ├── .eslintrc.cjs ├── .github ├── CODEOWNERS └── workflows │ ├── release-please.yml │ ├── stale.yml │ ├── test-action release-version.yml │ ├── test-action.yml │ ├── test.yml │ └── update-main-version.yml ├── .gitignore ├── .npmrc ├── .nvmrc ├── .prettierrc.json ├── .terragrunt-version ├── .terragrunt-version-latest ├── CHANGELOG.md ├── LICENSE ├── README.md ├── action.yml ├── lib └── index.js ├── package-lock.json ├── package.json ├── renovate.json ├── src ├── action.ts ├── get-inputs-and-outputs.ts ├── index.ts └── interfaces.ts ├── test ├── .terragrunt-version ├── action.ts └── get-inputs-and-outputs.ts └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 2 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [Makefile] 12 | indent_size = 4 13 | indent_style = tab 14 | -------------------------------------------------------------------------------- /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | module.exports = { 3 | extends: [ 4 | /** 5 | * Here I simply want to disable all rules. I feel like a pretty strict 6 | * tsconfig already catches a lot of the recommended rules and I want to 7 | * avoid any mental overhead of unnecessary "duplicated warnings/errors". 8 | * If you want to go with the "default/recommended" version, simply 9 | * uncomment the following lines in the extends array. 10 | */ 11 | // "eslint:recommended", 12 | // "plugin:@typescript-eslint/recommended", 13 | // "plugin:@typescript-eslint/recommended-requiring-type-checking", 14 | /* This prettier extends is used to disable all the formatting rules that 15 | * are enabled by the different "recommended" rules. 16 | */ 17 | // "prettier", 18 | ], 19 | plugins: ["@typescript-eslint"], 20 | parser: "@typescript-eslint/parser", 21 | parserOptions: { 22 | project: true, 23 | tsconfigRootDir: __dirname, 24 | }, 25 | /** 26 | * You can use the rules inside these overrides to specify the rules you want 27 | * to use on a one by one / case by case basis. If you simply want to go with 28 | * the default, just remove or uncomment the whole "rules" section inside the 29 | * "overrides" property, and you are done. 30 | * 31 | * The following rules are my personal preference and reflect a subset of the 32 | * recommended options. They also include a lot of the more strict options NOT 33 | * included in the recommended ones. My goal is to simplify having a 34 | * consistent code base/code style, to avoid catchable bugs early and advocate 35 | * for usage of newer features of the language. 36 | **/ 37 | overrides: [ 38 | { 39 | // Enables type checking for typescript files. 40 | // Src for the overrides from here : 41 | // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts 42 | files: ["*.ts", "*.tsx", "*.mts", "*.cts"], 43 | rules: { 44 | // "eslint" rules 45 | // check https://eslint.org/docs/latest/rules/ for reference 46 | "no-cond-assign": ["error", "always"], 47 | eqeqeq: ["error"], 48 | "no-constant-binary-expression": "error", 49 | curly: "error", 50 | "default-case": "error", 51 | "default-case-last": "error", 52 | "no-constant-condition": "error", 53 | "no-duplicate-imports": "error", 54 | "no-fallthrough": "error", 55 | "use-isnan": "error", 56 | "arrow-body-style": ["error", "always"], 57 | "no-loss-of-precision": "error", 58 | "no-promise-executor-return": "error", 59 | // See "when not to use it", and check your use case, if you think this 60 | // rule should be disabled. 61 | "no-await-in-loop": "error", 62 | "no-useless-escape": "error", 63 | "prefer-object-spread": "error", 64 | "prefer-spread": "error", 65 | "no-empty": "error", 66 | "no-useless-catch": "error", 67 | // See "when not to use it", and check your use case, if you think this 68 | // rule should be disabled. 69 | "no-bitwise": "error", 70 | // typescript-eslint rules 71 | // check https://typescript-eslint.io/rules/ for reference 72 | "@typescript-eslint/array-type": "error", 73 | "@typescript-eslint/consistent-type-definitions": ["error", "type"], 74 | "@typescript-eslint/no-unnecessary-condition": "error", 75 | "@typescript-eslint/prefer-includes": "error", 76 | "@typescript-eslint/prefer-optional-chain": "error", 77 | "@typescript-eslint/prefer-reduce-type-parameter": "error", 78 | "@typescript-eslint/prefer-string-starts-ends-with": "error", 79 | "@typescript-eslint/ban-types": "error", 80 | "@typescript-eslint/no-explicit-any": "error", 81 | "@typescript-eslint/no-for-in-array": "error", 82 | "@typescript-eslint/no-unsafe-call": "error", 83 | "@typescript-eslint/no-unsafe-return": "error", 84 | "@typescript-eslint/no-unsafe-member-access": "error", 85 | "@typescript-eslint/no-var-requires": "error", 86 | "@typescript-eslint/restrict-plus-operands": "error", 87 | }, 88 | }, 89 | ], 90 | root: true, 91 | }; 92 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * autero1 2 | -------------------------------------------------------------------------------- /.github/workflows/release-please.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | workflow_dispatch: 6 | name: release-please 7 | env: 8 | ACTION_NAME: action-terragrunt 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | - uses: actions/setup-node@v4 15 | with: 16 | node-version-file: ".nvmrc" 17 | - name: install 18 | run: npm ci 19 | - name: build 20 | run: npm run build 21 | - name: commit 22 | run: |- 23 | set -e 24 | # get current commit hash 25 | CURRENT_HASH=$(git rev-parse HEAD) 26 | # get last commit hash of last build lib 27 | LAST_BUILD_HASH=$(git log --author=google-github-actions-bot -1 --pretty=format:"%H") 28 | DIFF="" 29 | # build and commit lib if diff 30 | git config --global user.name "actions-bot" 31 | git config user.email 'github-actions-bot@google.com' 32 | git add lib/ 33 | git diff-index --quiet HEAD || git commit -m "chore: build lib ${ACTION_NAME}" 34 | # if last commit hash of last build lib was found, get logs of commits in btw for PR body 35 | if [ -z "$LAST_BUILD_HASH" ] 36 | then 37 | echo "Unable to find last commit by bot, skipping diff gen" 38 | else 39 | DIFF=$(git log ${LAST_BUILD_HASH}...${CURRENT_HASH} --oneline) 40 | echo $DIFF 41 | fi 42 | # set env vars 43 | echo "CURRENT_HASH=${CURRENT_HASH}" >> $GITHUB_ENV 44 | echo "LAST_BUILD_HASH=${LAST_BUILD_HASH}" >> $GITHUB_ENV 45 | echo 'DIFF<> $GITHUB_ENV 46 | echo "${DIFF}" >> $GITHUB_ENV 47 | echo 'EOF' >> $GITHUB_ENV 48 | - name: Create PR with lib 49 | uses: peter-evans/create-pull-request@v6 50 | with: 51 | token: ${{ secrets.GITHUB_TOKEN }} 52 | commit-message: Build lib 53 | author: "actions-bot " 54 | title: "chore: build lib" 55 | body: | 56 | Build lib PR 57 | ${{env.DIFF}} 58 | labels: automated pr 59 | branch: create-pull-request/build-lib 60 | delete-branch: true 61 | release-please-release: 62 | runs-on: ubuntu-latest 63 | needs: [build] 64 | steps: 65 | - uses: google-github-actions/release-please-action@v4 66 | id: release 67 | with: 68 | token: ${{ secrets.GITHUB_TOKEN }} 69 | release-type: node 70 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: "Stale" 2 | 3 | on: 4 | schedule: 5 | - cron: "6 6 * * *" 6 | 7 | jobs: 8 | stale: 9 | runs-on: ubuntu-22.04 10 | steps: 11 | - uses: actions/stale@v9 12 | with: 13 | repo-token: ${{ secrets.GITHUB_TOKEN }} 14 | stale-issue-message: "This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days." 15 | stale-pr-message: "This pull request is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days." 16 | days-before-stale: 21 17 | days-before-close: 7 18 | -------------------------------------------------------------------------------- /.github/workflows/test-action release-version.yml: -------------------------------------------------------------------------------- 1 | name: Test Action Release Version 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | test-release-version: 8 | runs-on: "ubuntu-22.04" 9 | steps: 10 | - uses: autero1/action-terragrunt@v3 11 | with: 12 | terragrunt-version: 0.55.0 13 | - name: Validate 14 | run: terragrunt --version 15 | - uses: autero1/action-terragrunt@v3 16 | with: 17 | terragrunt-version: latest 18 | - name: Validate 19 | run: terragrunt --version 20 | -------------------------------------------------------------------------------- /.github/workflows/test-action.yml: -------------------------------------------------------------------------------- 1 | name: Test Action 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - "**" 8 | # A pull request sent from a fork of the upstream repository could be manipulated to do harmful things. 9 | # The upstream repository’s maintainer would have no protection against this attack, as pull requests 10 | # can be sent by anyone who forks the repository on GitHub. 11 | # This is why we don't run automated tests on every PR. 12 | # pull_request: 13 | # types: 14 | # - opened 15 | # - synchronize 16 | # paths-ignore: 17 | # - '*.md' 18 | 19 | jobs: 20 | skipci: 21 | runs-on: ubuntu-22.04 22 | steps: 23 | - run: echo "[Skip CI] ${{ contains(github.event.head_commit.message, '[skip ci]') }}" 24 | 25 | test: 26 | runs-on: ${{ matrix.os }} 27 | if: contains(github.event.head_commit.message, '[skip ci]') == false 28 | strategy: 29 | max-parallel: 1 30 | matrix: 31 | os: 32 | - "ubuntu-22.04" 33 | - "macos-latest" 34 | - "windows-latest" 35 | steps: 36 | - uses: actions/checkout@v4 37 | 38 | - name: Setup Node 39 | uses: actions/setup-node@v4 40 | with: 41 | node-version-file: ".nvmrc" 42 | 43 | - run: npm ci 44 | 45 | - name: Remove lint-staged husky 46 | run: | 47 | npm uninstall lint-staged husky 48 | git checkout package-lock.json package.json 49 | 50 | - run: npm run build 51 | 52 | - name: Install specific Terragrunt version 53 | uses: ./ 54 | with: 55 | terragrunt-version: 0.54.0 56 | 57 | - name: Validate specific version 58 | run: terragrunt --version 59 | 60 | - name: Install latest Terragrunt version 61 | uses: ./ 62 | with: 63 | terragrunt-version: latest 64 | token: ${{ secrets.GITHUB_TOKEN }} 65 | 66 | - name: Validate latest 67 | run: terragrunt --version 68 | 69 | - name: Install Terragrunt with version file specified version 70 | uses: ./ 71 | with: 72 | terragrunt-version-file: .terragrunt-version 73 | token: ${{ secrets.GITHUB_TOKEN }} 74 | 75 | - name: Validate version file specified version 76 | run: terragrunt --version 77 | 78 | - name: Install Terragrunt with version file latest 79 | uses: ./ 80 | with: 81 | terragrunt-version-file: .terragrunt-version-latest 82 | token: ${{ secrets.GITHUB_TOKEN }} 83 | 84 | - name: Validate version file latest 85 | run: terragrunt --version 86 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: "Test" 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - "**" 8 | 9 | # A pull request sent from a fork of the upstream repository could be manipulated to do harmful things. 10 | # The upstream repository’s maintainer would have no protection against this attack, as pull requests 11 | # can be sent by anyone who forks the repository on GitHub. 12 | # This is why we don't run automated tests on every PR. 13 | # pull_request: 14 | # types: 15 | # - opened 16 | # - synchronize 17 | # paths-ignore: 18 | # - '*.md' 19 | 20 | jobs: 21 | skipci: 22 | runs-on: ubuntu-22.04 23 | steps: 24 | - run: echo "[Skip CI] ${{ contains(github.event.head_commit.message, '[skip ci]') }}" 25 | 26 | test: 27 | runs-on: ${{ matrix.os }} 28 | if: contains(github.event.head_commit.message, '[skip ci]') == false 29 | strategy: 30 | matrix: 31 | os: 32 | - "ubuntu-22.04" 33 | - "macos-latest" 34 | - "windows-latest" 35 | steps: 36 | - uses: actions/checkout@v4 37 | 38 | - name: Setup Node 39 | uses: actions/setup-node@v4 40 | with: 41 | node-version-file: ".nvmrc" 42 | 43 | - run: npm ci 44 | 45 | - name: Run prettier 46 | if: startsWith(matrix.os, 'ubuntu') 47 | run: npm run format:check 48 | 49 | - name: Run eslint 50 | if: startsWith(matrix.os, 'ubuntu') 51 | run: npm run lint 52 | 53 | - name: Run ncc 54 | if: startsWith(matrix.os, 'ubuntu') 55 | run: npm run build 56 | 57 | - run: npm test 58 | -------------------------------------------------------------------------------- /.github/workflows/update-main-version.yml: -------------------------------------------------------------------------------- 1 | name: Update Main Version 2 | run-name: Move ${{ github.event.inputs.major_version }} to ${{ github.event.inputs.target }} 3 | 4 | on: 5 | workflow_dispatch: 6 | inputs: 7 | target: 8 | description: The tag or reference to use 9 | required: true 10 | major_version: 11 | type: choice 12 | description: The major version to update 13 | options: 14 | - v2 15 | - v3 16 | 17 | jobs: 18 | tag: 19 | runs-on: ubuntu-latest 20 | steps: 21 | - uses: actions/checkout@v4 22 | with: 23 | fetch-depth: 0 24 | - name: Git config 25 | run: | 26 | git config user.name github-actions 27 | git config user.email github-actions@github.com 28 | - name: Tag new target 29 | run: git tag -f ${{ github.event.inputs.major_version }} ${{ github.event.inputs.target }} 30 | - name: Push new tag 31 | run: git push origin ${{ github.event.inputs.major_version }} --force 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | coverage 3 | .npm 4 | .eslintcache 5 | .env 6 | node_modules 7 | .idea 8 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 20.11.1 2 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": true, 6 | "singleQuote": true, 7 | "trailingComma": "none", 8 | "bracketSpacing": false, 9 | "arrowParens": "avoid", 10 | "parser": "typescript" 11 | } 12 | -------------------------------------------------------------------------------- /.terragrunt-version: -------------------------------------------------------------------------------- 1 | 0.51.0 2 | -------------------------------------------------------------------------------- /.terragrunt-version-latest: -------------------------------------------------------------------------------- 1 | latest 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [3.0.2](https://github.com/autero1/action-terragrunt/compare/v3.0.1...v3.0.2) (2024-02-23) 4 | 5 | 6 | ### Bug Fixes 7 | 8 | * Add build assets ([#364](https://github.com/autero1/action-terragrunt/issues/364)) ([fbf57bc](https://github.com/autero1/action-terragrunt/commit/fbf57bc433aed5187d2e745446f2419812152f8c)) 9 | * add release assets ([3a76193](https://github.com/autero1/action-terragrunt/commit/3a76193b51ee86b2d323f3e8af9a1a778bd805e2)) 10 | * add release assets ([393ac34](https://github.com/autero1/action-terragrunt/commit/393ac341d39571e7dc22a18f04d80005b47cd2d5)) 11 | * add release assets ([c53f921](https://github.com/autero1/action-terragrunt/commit/c53f921686ba808ddcb498879db5c842ee337f04)) 12 | * add release assets ([cad37c7](https://github.com/autero1/action-terragrunt/commit/cad37c7dc4ca97e8647320457fcbea74f32042ba)) 13 | * **build:** add release assets PR creation ([#365](https://github.com/autero1/action-terragrunt/issues/365)) ([24242c3](https://github.com/autero1/action-terragrunt/commit/24242c3c1939ffeede02edc8f798c4f5158df72a)) 14 | * **deps:** update dependency @types/node to v20.11.20 ([#363](https://github.com/autero1/action-terragrunt/issues/363)) ([71fb2ea](https://github.com/autero1/action-terragrunt/commit/71fb2eafa29729c9e3c006cb83536e64d80d26c2)) 15 | * **deps:** update dependency node to v20.11.1 ([#356](https://github.com/autero1/action-terragrunt/issues/356)) ([870bacd](https://github.com/autero1/action-terragrunt/commit/870bacd3fd0dffc17f5f3936549b0ce77f307f96)) 16 | * **deps:** update typescript-eslint monorepo to v7.0.2 ([#361](https://github.com/autero1/action-terragrunt/issues/361)) ([1dc625a](https://github.com/autero1/action-terragrunt/commit/1dc625a2683c48a6e34d6f30f9dd6275cb650823)) 17 | 18 | ## [3.0.1](https://github.com/autero1/action-terragrunt/compare/v3.0.0...v3.0.1) (2024-02-19) 19 | 20 | 21 | ### Bug Fixes 22 | 23 | * **lint:** resolve linting issues across the codebase ([22304b0](https://github.com/autero1/action-terragrunt/commit/22304b0ef1e8a1af51e0b6403dd134cc0e2f2c99)) 24 | * **release:** fix release-please configuration ([#354](https://github.com/autero1/action-terragrunt/issues/354)) ([d568e25](https://github.com/autero1/action-terragrunt/commit/d568e2550c289e3cfa25247ebe2aef76e07c0e70)) 25 | * **release:** fix release-please configuration and CHANGELOG.md formatting ([#352](https://github.com/autero1/action-terragrunt/issues/352)) ([4d12d72](https://github.com/autero1/action-terragrunt/commit/4d12d72ced25a11ac99a6acf709cfad540d01448)) 26 | * **tests:** use proper glob pattern to run tests on all branches ([22304b0](https://github.com/autero1/action-terragrunt/commit/22304b0ef1e8a1af51e0b6403dd134cc0e2f2c99)) 27 | 28 | ## [3.0.0](https://github.com/autero1/action-terragrunt/compare/v2.0.0...v3.0.0) (2024-02-18) 29 | 30 | 31 | ### ⚠ BREAKING CHANGES 32 | 33 | * change input/output vars underscores to dashes 34 | * use an optional version file to specify Terragrunt version (one of `terragrunt-version` or `terragrunt-version-file` required) 35 | 36 | ### Features 37 | 38 | * use an optional version file to specify Terragrunt version (one of `terragrunt-version` or `terragrunt-version-file` required) ([ea717b1](https://github.com/autero1/action-terragrunt/commit/ea717b1be44da5d5d4f6b9bc07688c1945d766d7)) 39 | * use release-please instead of manual release process ([#347](https://github.com/autero1/action-terragrunt/issues/347)) ([46abb67](https://github.com/autero1/action-terragrunt/commit/46abb67fe1471e7458d19b2920ee0237892aaafc)) 40 | 41 | 42 | ### Bug Fixes 43 | 44 | * fix formatting ([#348](https://github.com/autero1/action-terragrunt/issues/348)) ([ffcb03c](https://github.com/autero1/action-terragrunt/commit/ffcb03c8cf39ea7489d53fc80e67689c318bfbed)) 45 | 46 | 47 | ### Code Refactoring 48 | 49 | * change input/output vars underscores to dashes ([ea717b1](https://github.com/autero1/action-terragrunt/commit/ea717b1be44da5d5d4f6b9bc07688c1945d766d7)) 50 | 51 | 52 | 53 | 54 | ## [2.0.0](https://github.com/autero1/action-terragrunt/compare/v1.3.2...v2.0.0) (2024-02-17) 55 | 56 | ### chore 57 | 58 | * bump dependencies ([5853e32](https://github.com/autero1/action-terragrunt/commit/5853e327548746e7f8044d26a47e97de912f33a3)) 59 | 60 | ### test 61 | 62 | * install 0.54.0 terragrunt in test ([f9da40a](https://github.com/autero1/action-terragrunt/commit/f9da40a1acbeb5c62601a5ba9b6f067a86cd518e)) 63 | * only upload ubuntu coverage ([a4f7188](https://github.com/autero1/action-terragrunt/commit/a4f7188b08b0bee271c08dc81ae828860a9834d3)) 64 | * restore got for the time being ([9a2698f](https://github.com/autero1/action-terragrunt/commit/9a2698f760748ca2930d82a358c7e5bd14bac9b3)) 65 | 66 | 67 | 68 | ## [1.3.2](https://github.com/autero1/action-terragrunt/compare/v1.3.1...v1.3.2) (2023-05-18) 69 | 70 | 71 | ### chore 72 | 73 | * upgrade actions runners ([563c789](https://github.com/autero1/action-terragrunt/commit/563c789ec8329b843cda989b95ca6a6709814b6f)) 74 | 75 | ### fix 76 | 77 | * use tag instead of name for latestRelease ([1acad56](https://github.com/autero1/action-terragrunt/commit/1acad564aa48ef43b0e77521a705975b4f90434d)) 78 | 79 | ### test 80 | 81 | * mock os architecture ([02a9d37](https://github.com/autero1/action-terragrunt/commit/02a9d37ea715bff4a5b304be8f2fc7f4d3cf466f)) 82 | 83 | 84 | 85 | ## [1.3.1](https://github.com/autero1/action-terragrunt/compare/v1.3.0...v1.3.1) (2023-03-04) 86 | 87 | 88 | 89 | 90 | ## [1.3.0](https://github.com/autero1/action-terragrunt/compare/v1.2.0...v1.3.0) (2023-01-24) 91 | 92 | 93 | ### feat 94 | 95 | * add github api token input ([318b30a](https://github.com/autero1/action-terragrunt/commit/318b30a44f5bbc0d6a26e1b24943b8e82993da2f)) 96 | 97 | 98 | 99 | ## [1.2.0](https://github.com/autero1/action-terragrunt/compare/v1.1.1...v1.2.0) (2022-10-23) 100 | 101 | 102 | ### ci 103 | 104 | * adds dependabot and removes set-output ([9dfad21](https://github.com/autero1/action-terragrunt/commit/9dfad210201719258722bec257b0139aaa5277d6)) 105 | * fix jest/got issue ([13cd122](https://github.com/autero1/action-terragrunt/commit/13cd122986927d25c6006bf2e1409e600d9daa2e)) 106 | * increases limit of dependabot PRs ([bc7790c](https://github.com/autero1/action-terragrunt/commit/bc7790cbc3a7f3309e0e5a48530592690e0d837a)) 107 | * prettier fix ([cb464b4](https://github.com/autero1/action-terragrunt/commit/cb464b42c1f941d7983ac4562971bd33b85aeae6)) 108 | * updates nodejs ([860c045](https://github.com/autero1/action-terragrunt/commit/860c04594b3cb957c4893588eb761411686ed1dd)) 109 | * updates nodejs in action.yml ([4a5561d](https://github.com/autero1/action-terragrunt/commit/4a5561d0242b7d58c90a48fdc876c0ef69bf158c)) 110 | 111 | 112 | 113 | ## [1.1.1](https://github.com/autero1/action-terragrunt/compare/v1.1.0...v1.1.1) (2021-09-03) 114 | 115 | 116 | 117 | 118 | ## [1.1.0](https://github.com/autero1/action-terragrunt/compare/v1.0.1...v1.1.0) (2021-04-04) 119 | 120 | 121 | ### feat 122 | 123 | * add ability to get latest Terragrunt version (#11) ([989a3e6](https://github.com/autero1/action-terragrunt/commit/989a3e649c2b234217eb6576af09a39916d94fbf)), closes [#11](https://github.com/autero1/action-terragrunt/issues/11) 124 | 125 | 126 | 127 | ## [1.0.1](https://github.com/autero1/action-terragrunt/compare/v1.0.0...v1.0.1) (2021-02-09) 128 | 129 | - Update packages to latest versions 130 | 131 | 132 | ## [1.0.0](https://github.com/autero1/action-terragrunt/compare/v0.1.0...v1.0.0) (2020-12-15) 133 | 134 | - Fix CVE-2020-15228 with GitHub Actions Path and Environment variables 135 | - Update packages to latest versions 136 | - Migrate @zeit/ncc to @vercel/ncc 137 | 138 | 139 | 140 | ## 0.1.0 (2020-02-16) 141 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2020 Petri Autero (autero1) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![license](https://img.shields.io/github/license/autero1/action-terragrunt)](https://github.com/autero1/action-terragrunt/blob/main/LICENSE) 2 | [![release](https://img.shields.io/github/release/autero1/action-terragrunt.svg)](https://github.com/autero1/action-terragrunt/releases/latest) 3 | [![GitHub release date](https://img.shields.io/github/release-date/autero1/action-terragrunt.svg)](https://github.com/autero1/action-terragrunt/releases) 4 | [![Test Action](https://github.com/autero1/action-terragrunt/actions/workflows/test-action.yml/badge.svg?branch=main)](https://github.com/autero1/action-terragrunt/actions/workflows/test-action.yml) 5 | [![CodeFactor](https://www.codefactor.io/repository/github/autero1/action-terragrunt/badge)](https://www.codefactor.io/repository/github/autero1/action-terragrunt) 6 | 7 | # Setup Terragrunt GitHub Action 8 | 9 | Set up your GitHub Actions workflow with a specific version of [Terragrunt](https://terragrunt.gruntwork.io/). You can optionally set version to `latest` to use the most recent version. 10 | 11 | Because of [deprecation in the GitHub Actions environment](https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/), versions lower than v1.0.0 will no longer work properly. 12 | 13 | ## Special Notice 14 | 15 | From version `v3.0.0`, the inputs and outputs are changed to dash-separated version (`terragrunt-version`, `terragrunt-version-file`, `terragrunt-path`). 16 | 17 | This convention aligns with the YAML style guide and is more prevalent in the GitHub Actions community and documentation. 18 | 19 | ## Usage 20 | 21 | The next example step will install Terragrunt 0.55.2. 22 | 23 | ```yaml 24 | name: Example workflow 25 | 26 | on: [push] 27 | 28 | jobs: 29 | example: 30 | name: Example Terragrunt interaction 31 | runs-on: ubuntu-latest 32 | steps: 33 | - name: Checkout 34 | uses: actions/checkout@v2 35 | - name: Setup Terragrunt 36 | uses: autero1/action-terragrunt@v3 37 | with: 38 | terragrunt-version: 0.55.2 39 | token: ${{ secrets.GITHUB_TOKEN }} 40 | - name: Interact with Terragrunt 41 | run: terragrunt --version 42 | ``` 43 | If you want to use a version file, e.g. `.terragrunt-version`, you can use the following example: 44 | 45 | ```yaml 46 | name: Example workflow with version file 47 | 48 | on: [push] 49 | 50 | jobs: 51 | example: 52 | name: Example Terragrunt interaction 53 | runs-on: ubuntu-latest 54 | steps: 55 | - name: Checkout 56 | uses: actions/checkout@v2 57 | - name: Setup Terragrunt 58 | uses: autero1/action-terragrunt@v3 59 | with: 60 | terragrunt-version-file: .terragrunt-version 61 | token: ${{ secrets.GITHUB_TOKEN }} 62 | - name: Interact with Terragrunt 63 | run: terragrunt --version 64 | 65 | ``` 66 | 67 | ### Inputs 68 | 69 | | Parameter | Description | Required | 70 | |---------------------------|--------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------| 71 | | `terragrunt-version` | Terragrunt [version](https://github.com/gruntwork-io/terragrunt/releases) to deploy. Use `latest` for the most recent version. | either version or version file required | 72 | | `terragrunt-version-file` | File containing the Terragrunt version to install. | either version or version file required | 73 | | `token` | Github API Token to avoid rate limiting while getting latest Terragrunt release | false | 74 | 75 | ### Outputs 76 | 77 | | Parameter | Description | 78 | |-------------------| ----------- | 79 | | `terragrunt-path` | Cached tool path of Terragrunt | 80 | 81 | ### Supported platforms 82 | 83 | This action has been tested on the following platforms: 84 | 85 | * ubuntu-22.04 86 | * windows-latest 87 | * macos-latest 88 | 89 | 90 | ## Contributing 91 | 92 | Contributions to this repository are very welcome! We follow a fairly standard [pull request process]( 93 | https://help.github.com/articles/about-pull-requests/) for contributions, subject to the following guidelines: 94 | 95 | 1. File a GitHub issue 96 | 1. Fork the repository 97 | 1. Update the documentation 98 | 1. Update the tests 99 | 1. Update the code 100 | 1. Create a pull request 101 | 1. (Merge and release) 102 | 103 | The maintainers for this repo will review your code and provide feedback. If everything looks good, they will merge the 104 | code and release a new version, which you'll be able to find in the [releases page](../../releases). Release process is automated using [release-please](https://github.com/googleapis/release-please). 105 | 106 | ## License 107 | 108 | The scripts and documentation in this project are released under the [MIT](./LICENSE) license. 109 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Terragrunt installer' 2 | description: 'Install a specific version of terragrunt binary.' 3 | author: 'Petri Autero' 4 | inputs: 5 | terragrunt-version: 6 | description: 'Terragrunt version to install. Examples: 0.52.0, latest' 7 | terragrunt-version-file: 8 | description: 'File containing the Terragrunt version to install. Examples: .terragrunt-version' 9 | token: 10 | description: 'Github token to use for getting latest release' 11 | outputs: 12 | terragrunt-path: 13 | description: 'Path to the terragrunt binary' 14 | branding: 15 | icon: cloud 16 | color: 'orange' 17 | runs: 18 | using: 'node20' 19 | main: 'lib/index.js' 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "action-terragrunt", 3 | "version": "3.0.2", 4 | "description": "GitHub action for setting up Terragrunt", 5 | "author": "Petri Autero", 6 | "license": "MIT", 7 | "dependencies": { 8 | "@actions/core": "^1.10.1", 9 | "@actions/exec": "^1.1.1", 10 | "@actions/io": "^1.1.3", 11 | "@actions/tool-cache": "^2.0.1", 12 | "@octokit/rest": "^20.0.2" 13 | }, 14 | "main": "lib/index.js", 15 | "engines": { 16 | "node": ">=20.0.0", 17 | "npm": ">=8.0.0" 18 | }, 19 | "scripts": { 20 | "lint": "eslint ./{src,test}/**/*.ts", 21 | "lint:fix": "eslint --fix ./{src,test}/**/*.ts", 22 | "test": "glob \"src/**/*.test.ts\" \"test/**\" -c \"tsx --test\"", 23 | "build": "ncc build ./src/index.ts -o lib", 24 | "tsc": "tsc", 25 | "format": "prettier --write **/*.ts", 26 | "format:check": "prettier --check **/*.ts", 27 | "update-deps": "(git diff 'HEAD@{1}' --name-only | grep 'package-lock.json' > /dev/null) && npm ci || :" 28 | }, 29 | "husky": { 30 | "skipCI": true, 31 | "hooks": { 32 | "pre-commit": "lint-staged", 33 | "post-merge": "npm run update-deps; git remote prune origin" 34 | } 35 | }, 36 | "lint-staged": { 37 | "src/**/*.ts": [ 38 | "prettier --check", 39 | "eslint" 40 | ] 41 | }, 42 | "repository": { 43 | "type": "git", 44 | "url": "git+https://github.com/autero1/action-terragrunt.git" 45 | }, 46 | "keywords": [ 47 | "GitHub Actions", 48 | "Actions", 49 | "JavaScript Action", 50 | "TypeScript Action", 51 | "Terragrunt", 52 | "Terraform" 53 | ], 54 | "devDependencies": { 55 | "@tsconfig/node20": "^20.1.2", 56 | "@types/got": "^9.6.12", 57 | "@types/node": "^20.11.19", 58 | "@typescript-eslint/eslint-plugin": "^7.0.1", 59 | "@typescript-eslint/parser": "^7.0.1", 60 | "@vercel/ncc": "^0.38.1", 61 | "eslint": "^8.56.0", 62 | "glob": "^10.3.10", 63 | "got": "^14.2.0", 64 | "husky": "^9.0.11", 65 | "lint-staged": "^15.2.2", 66 | "prettier": "^3.2.5", 67 | "tsx": "^4.7.1", 68 | "typescript": "^5.3.3" 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:recommended" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /src/action.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core'; 2 | import * as toolCache from '@actions/tool-cache'; 3 | import * as fs from 'fs'; 4 | import * as os from 'os'; 5 | import * as path from 'path'; 6 | import * as util from 'util'; 7 | import {Octokit} from '@octokit/rest'; 8 | import {getInputs, getOutputs} from './get-inputs-and-outputs'; 9 | 10 | const executableName = 'terragrunt'; 11 | const fullExecutableFormat = 'terragrunt_%s_%s'; 12 | const downloadUrlFormat = `https://github.com/gruntwork-io/terragrunt/releases/download/%s/${fullExecutableFormat}`; 13 | 14 | export function getExecutableExtension(): string { 15 | if (os.type().match(/^Win/)) { 16 | return '.exe'; 17 | } 18 | return ''; 19 | } 20 | 21 | export function getArchName(): string { 22 | switch (os.arch()) { 23 | case 'x32': 24 | return '386'; 25 | 26 | case 'x64': 27 | return 'amd64'; 28 | 29 | case 'arm64': 30 | return 'arm64'; 31 | 32 | default: 33 | throw new Error(util.format('Unknown architecture ', os.arch())); 34 | } 35 | } 36 | 37 | export function getDownloadURL(version: string): string { 38 | const arch = getArchName(); 39 | 40 | switch (os.type()) { 41 | case 'Windows_NT': 42 | return `${util.format(downloadUrlFormat, version, 'windows', arch)}.exe`; 43 | 44 | case 'Darwin': 45 | return util.format(downloadUrlFormat, version, 'darwin', arch); 46 | 47 | case 'Linux': 48 | default: 49 | return util.format(downloadUrlFormat, version, 'linux', arch); 50 | } 51 | } 52 | 53 | export const getLatestVersion = async (): Promise => { 54 | const octokit = new Octokit({ 55 | auth: getInputs().GithubToken 56 | }); 57 | 58 | const latestRelease = await octokit.repos.getLatestRelease({ 59 | owner: 'gruntwork-io', 60 | repo: 'terragrunt' 61 | }); 62 | 63 | return latestRelease.data.tag_name; 64 | }; 65 | 66 | const walkSync = function ( 67 | dir: string, 68 | filelist: string[], 69 | fileToFind: string 70 | ): string[] { 71 | const files = fs.readdirSync(dir); 72 | files.forEach(function (file) { 73 | if (fs.statSync(path.join(dir, file)).isDirectory()) { 74 | filelist = walkSync(path.join(dir, file), filelist, fileToFind); 75 | } else { 76 | core.debug(file); 77 | if (file === fileToFind) { 78 | filelist.push(path.join(dir, file)); 79 | } 80 | } 81 | }); 82 | return filelist; 83 | }; 84 | 85 | export function findExecutable(rootFolder: string): string { 86 | fs.chmodSync(rootFolder, '777'); 87 | const filelist: string[] = []; 88 | walkSync(rootFolder, filelist, executableName + getExecutableExtension()); 89 | if (filelist.length === 0) { 90 | throw new Error( 91 | util.format('Terragrunt executable not found in path ', rootFolder) 92 | ); 93 | } else { 94 | return filelist[0]; 95 | } 96 | } 97 | 98 | export async function downloadTerragrunt(version: string): Promise { 99 | core.info(`[INFO] Setting up Terragrunt version: '${version}'`); 100 | 101 | let actualVersion = version; 102 | 103 | // Get latest version number and reassign version param to it. 104 | if (version.toLowerCase() === 'latest') { 105 | const latestVersion = await getLatestVersion(); 106 | actualVersion = latestVersion || ''; 107 | core.info(`[INFO] Latest Terragrunt version: '${actualVersion}'`); 108 | } 109 | 110 | // See if we already have it installed 111 | let cachedToolpath = toolCache.find(executableName, actualVersion); 112 | if (!cachedToolpath) { 113 | let dlPath: string; 114 | const dlURL = getDownloadURL(actualVersion); 115 | core.info(`[INFO] Downloading from: '${dlURL}'`); 116 | try { 117 | dlPath = await toolCache.downloadTool(dlURL); 118 | } catch (exception) { 119 | throw new Error( 120 | util.format('Failed to download Terragrunt from ', dlURL) 121 | ); 122 | } 123 | 124 | // Changing temp path permissions 125 | fs.chmodSync(dlPath, '777'); 126 | 127 | // Cache the tool 128 | cachedToolpath = await toolCache.cacheFile( 129 | dlPath, 130 | executableName + getExecutableExtension(), 131 | executableName, 132 | actualVersion 133 | ); 134 | } 135 | 136 | const executablePath = findExecutable(cachedToolpath); 137 | if (!executablePath) { 138 | throw new Error( 139 | util.format('Terragrunt executable not found in path ', cachedToolpath) 140 | ); 141 | } 142 | 143 | fs.chmodSync(executablePath, '777'); 144 | return executablePath; 145 | } 146 | 147 | export async function run(): Promise { 148 | const terragruntVersion: string = getInputs().TerragruntVersion; 149 | 150 | const cachedPath = await downloadTerragrunt(terragruntVersion); 151 | 152 | // Add the cached tool to path 153 | core.addPath(path.dirname(cachedPath)); 154 | core.info( 155 | `[INFO] Terragrunt version: '${terragruntVersion}' has been cached at ${cachedPath}` 156 | ); 157 | core.setOutput(getOutputs().TerragruntPath, cachedPath); 158 | } 159 | -------------------------------------------------------------------------------- /src/get-inputs-and-outputs.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core'; 2 | import fs from 'fs'; 3 | import * as path from 'path'; 4 | import {Inputs, Outputs} from './interfaces'; 5 | 6 | function showInputs(inps: Inputs): void { 7 | core.info(`[INFO] TerragruntVersion: ${inps.TerragruntVersion}`); 8 | } 9 | 10 | export function getTerragruntVersionFromFile(versionFilePath: string): string { 11 | if (!fs.existsSync(versionFilePath)) { 12 | throw new Error( 13 | `The specified Terragrunt version file at: ${versionFilePath} does not exist` 14 | ); 15 | } 16 | 17 | const contents = fs.readFileSync(versionFilePath, 'utf8'); 18 | return contents.trim().replace(/\r?\n|\r/g, ''); 19 | } 20 | 21 | function prepareInputs(tgVersion: string): Inputs { 22 | if ( 23 | tgVersion && 24 | !tgVersion.startsWith('v') && 25 | tgVersion.toLowerCase() !== 'latest' 26 | ) { 27 | tgVersion = `v${tgVersion}`; 28 | } 29 | 30 | const token = core.getInput('token') || undefined; 31 | 32 | const inps: Inputs = { 33 | TerragruntVersion: tgVersion, 34 | GithubToken: token 35 | }; 36 | 37 | showInputs(inps); 38 | 39 | return inps; 40 | } 41 | 42 | export function getInputs(): Inputs { 43 | let tgVersion = core.getInput('terragrunt-version'); 44 | const tgVersionFile = core.getInput('terragrunt-version-file'); 45 | 46 | if (tgVersion && tgVersionFile) { 47 | core.warning( 48 | '[WARN] Both terragrunt-version and terragrunt-version-file inputs are specified. Only terragrunt-version will be used' 49 | ); 50 | return prepareInputs(tgVersion); 51 | } 52 | 53 | if (tgVersionFile) { 54 | const versionFilePath = path.join( 55 | process.env.GITHUB_WORKSPACE!, 56 | tgVersionFile 57 | ); 58 | 59 | tgVersion = getTerragruntVersionFromFile(versionFilePath); 60 | } 61 | return prepareInputs(tgVersion); 62 | } 63 | 64 | export function getOutputs(): Outputs { 65 | const outs: Outputs = { 66 | TerragruntPath: 'terragrunt-path' 67 | }; 68 | 69 | return outs; 70 | } 71 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core'; 2 | import {run} from './action'; 3 | 4 | (async (): Promise => { 5 | try { 6 | await run(); 7 | } catch (e) { 8 | core.setFailed(`Action failed with "${e}"`); 9 | } 10 | })(); 11 | -------------------------------------------------------------------------------- /src/interfaces.ts: -------------------------------------------------------------------------------- 1 | export type Inputs = { 2 | readonly TerragruntVersion: string; 3 | readonly GithubToken?: string; 4 | }; 5 | 6 | export type Outputs = { 7 | readonly TerragruntPath: string; 8 | }; 9 | -------------------------------------------------------------------------------- /test/.terragrunt-version: -------------------------------------------------------------------------------- 1 | 0.50.0 2 | -------------------------------------------------------------------------------- /test/action.ts: -------------------------------------------------------------------------------- 1 | import * as assert from 'assert'; 2 | import os from 'node:os'; 3 | import {getDownloadURL, getLatestVersion} from '../src/action'; 4 | import got from 'got'; 5 | import {afterEach, describe, it, mock} from 'node:test'; 6 | 7 | afterEach(() => { 8 | delete process.env['INPUT_TERRAGRUNT-VERSION']; 9 | delete process.env['INPUT_TERRAGRUNT-VERSION-FILE']; 10 | delete process.env['GITHUB_WORKSPACE']; 11 | mock.reset(); 12 | mock.restoreAll(); 13 | }); 14 | 15 | async function checkHead(url: string): Promise { 16 | const response = await got.get(url, {followRedirect: false}); 17 | return response.statusCode; 18 | } 19 | 20 | describe('getDownloadURL()', () => { 21 | it('get windows url', async () => { 22 | mock.method(os, 'type', () => { 23 | return 'Windows_NT'; 24 | }); 25 | mock.method(os, 'arch', () => { 26 | return 'x64'; 27 | }); 28 | const winDLUrl = getDownloadURL('v0.21.13'); 29 | assert.strictEqual( 30 | winDLUrl, 31 | 'https://github.com/gruntwork-io/terragrunt/releases/download/v0.21.13/terragrunt_windows_amd64.exe' 32 | ); 33 | assert.strictEqual(await checkHead(winDLUrl), 302); 34 | }); 35 | 36 | it('get darwin url', async () => { 37 | mock.method(os, 'type', () => { 38 | return 'Darwin'; 39 | }); 40 | mock.method(os, 'arch', () => { 41 | return 'x64'; 42 | }); 43 | const darwinDLUrl = getDownloadURL('v0.21.13'); 44 | assert.strictEqual( 45 | darwinDLUrl, 46 | 'https://github.com/gruntwork-io/terragrunt/releases/download/v0.21.13/terragrunt_darwin_amd64' 47 | ); 48 | assert.strictEqual(await checkHead(darwinDLUrl), 302); 49 | }); 50 | 51 | it('get linux url', async () => { 52 | mock.method(os, 'type', () => { 53 | return 'Linux'; 54 | }); 55 | mock.method(os, 'arch', () => { 56 | return 'x64'; 57 | }); 58 | const linuxDLUrl = getDownloadURL('v0.21.13'); 59 | assert.strictEqual( 60 | linuxDLUrl, 61 | 'https://github.com/gruntwork-io/terragrunt/releases/download/v0.21.13/terragrunt_linux_amd64' 62 | ); 63 | assert.strictEqual(await checkHead(linuxDLUrl), 302); 64 | }); 65 | 66 | it('get latest url', async () => { 67 | process.env['INPUT_TERRAGRUNT-VERSION'] = 'latest'; 68 | const latestVersion = (await getLatestVersion()) || ''; 69 | mock.method(os, 'type', () => { 70 | return 'Linux'; 71 | }); 72 | mock.method(os, 'arch', () => { 73 | return 'x64'; 74 | }); 75 | const linuxDLUrl = getDownloadURL(latestVersion); 76 | assert.strictEqual(await checkHead(linuxDLUrl), 302); 77 | }); 78 | }); 79 | -------------------------------------------------------------------------------- /test/get-inputs-and-outputs.ts: -------------------------------------------------------------------------------- 1 | import {Inputs, Outputs} from '../src/interfaces'; 2 | import {getInputs, getOutputs} from '../src/get-inputs-and-outputs'; 3 | import assert from 'node:assert/strict'; 4 | import {afterEach, beforeEach, describe, it, mock} from 'node:test'; 5 | 6 | beforeEach(() => { 7 | mock.reset(); 8 | }); 9 | 10 | afterEach(() => { 11 | delete process.env['INPUT_TERRAGRUNT-VERSION']; 12 | delete process.env['INPUT_TERRAGRUNT-VERSION-FILE']; 13 | delete process.env['GITHUB_WORKSPACE']; 14 | }); 15 | 16 | describe('getInputs()', () => { 17 | it('should get proper value from version input', () => { 18 | process.env['INPUT_TERRAGRUNT-VERSION'] = 'v0.21.13'; 19 | 20 | const inputs: Inputs = getInputs(); 21 | 22 | assert.strictEqual(inputs.TerragruntVersion, 'v0.21.13'); 23 | }); 24 | 25 | it('should get proper value from input version file only', () => { 26 | process.env['GITHUB_WORKSPACE'] = './test'; 27 | process.env['INPUT_TERRAGRUNT-VERSION-FILE'] = '.terragrunt-version'; 28 | 29 | const inputs: Inputs = getInputs(); 30 | 31 | assert.strictEqual(inputs.TerragruntVersion, 'v0.50.0'); 32 | }); 33 | 34 | it('should get proper value from input version latest', () => { 35 | process.env['INPUT_TERRAGRUNT-VERSION'] = 'latest'; 36 | 37 | const inputs: Inputs = getInputs(); 38 | 39 | assert.strictEqual(inputs.TerragruntVersion, 'latest'); 40 | }); 41 | 42 | it('should get proper value from input version and version-file', () => { 43 | process.env['INPUT_TERRAGRUNT-VERSION'] = 'v0.22.0'; 44 | process.env['INPUT_TERRAGRUNT-VERSION-FILE'] = '.terragrunt-version'; 45 | 46 | const inputs: Inputs = getInputs(); 47 | 48 | assert.strictEqual(inputs.TerragruntVersion, 'v0.22.0'); 49 | }); 50 | 51 | it('should get proper value from neither input version or version-file', () => { 52 | const inputs: Inputs = getInputs(); 53 | assert.strictEqual(inputs.TerragruntVersion, ''); 54 | }); 55 | 56 | it('should prefix with v', () => { 57 | process.env['INPUT_TERRAGRUNT-VERSION'] = '0.21.13'; 58 | 59 | const inputs: Inputs = getInputs(); 60 | 61 | assert.strictEqual(inputs.TerragruntVersion, 'v0.21.13'); 62 | }); 63 | 64 | it('should get spec outputs', () => { 65 | const outputs: Outputs = getOutputs(); 66 | 67 | assert.strictEqual(outputs.TerragruntPath, 'terragrunt-path'); 68 | }); 69 | }); 70 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Basic Options */ 4 | // "incremental": true, /* Enable incremental compilation */ 5 | "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ 6 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ 7 | // "allowJs": true, /* Allow javascript files to be compiled. */ 8 | // "checkJs": true, /* Report errors in .js files. */ 9 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 10 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 11 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 12 | "sourceMap": true, /* Generates corresponding '.map' file. */ 13 | // "outFile": "./", /* Concatenate and emit output to single file. */ 14 | "outDir": "./lib", /* Redirect output structure to the directory. */ 15 | // "composite": true, /* Enable project compilation */ 16 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 17 | "removeComments": true, /* Do not emit comments to output. */ 18 | // "noEmit": true, /* Do not emit outputs. */ 19 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 20 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 21 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 22 | 23 | /* Strict Type-Checking Options */ 24 | "strict": true, /* Enable all strict type-checking options. */ 25 | "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 26 | // "strictNullChecks": true, /* Enable strict null checks. */ 27 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 28 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 29 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 30 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 31 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 32 | 33 | /* Additional Checks */ 34 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 35 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 36 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 37 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 38 | 39 | /* Module Resolution Options */ 40 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 41 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 42 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 43 | "rootDirs": ["./src", "./test"], /* List of root folders whose combined content represents the structure of the project at runtime. */ 44 | // "typeRoots": [], /* List of folders to include type definitions from. */ 45 | // "types": [], /* Type declaration files to be included in compilation. */ 46 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 47 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 48 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 49 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 50 | 51 | /* Source Map Options */ 52 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 53 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 54 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 55 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 56 | 57 | /* Experimental Options */ 58 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 59 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 60 | 61 | "resolveJsonModule": true 62 | }, 63 | "exclude": ["node_modules", "lib"], 64 | "include": ["src", "test"] 65 | } 66 | --------------------------------------------------------------------------------