From 58c03e3dd5f6260ead26620cdc4162a276f85139 Mon Sep 17 00:00:00 2001 From: Greg Schofield Date: Wed, 22 Jun 2022 12:02:09 -0400 Subject: [PATCH 1/8] Update path to include ~/.local/bin --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index 8fb1aa8..fefc6f5 100644 --- a/action.yml +++ b/action.yml @@ -37,6 +37,7 @@ runs: fi if [ "${{ inputs.include-c7n-org }}" == true ]; then pip install c7n-org + export PATH=~/.local/bin/:$PATH fi dir=$(pwd) cat << EOF > /usr/local/bin/custodian From 463211b6550f4cf86f092c7e04f4cc846b7af296 Mon Sep 17 00:00:00 2001 From: Gregory Schofield Date: Wed, 22 Jun 2022 12:05:25 -0400 Subject: [PATCH 2/8] Remove path export from workflow Signed-off-by: Gregory Schofield --- .github/workflows/custodian.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/custodian.yml b/.github/workflows/custodian.yml index dabdb74..6aa52bb 100644 --- a/.github/workflows/custodian.yml +++ b/.github/workflows/custodian.yml @@ -25,8 +25,6 @@ jobs: run: | custodian schema custodian version - echo "export PATH=\"`python3 -m site --user-base`/bin:\$PATH\"" >> ~/.bashrc - source ~/.bashrc c7n-org --help - name: Install Specific Version uses: ./ From 55e193b943d3546655af0d2c069921ddb4eee6fe Mon Sep 17 00:00:00 2001 From: Gregory Schofield Date: Wed, 22 Jun 2022 12:10:55 -0400 Subject: [PATCH 3/8] Use ln instead of exporting PATH Signed-off-by: Gregory Schofield --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index fefc6f5..aaec464 100644 --- a/action.yml +++ b/action.yml @@ -37,7 +37,7 @@ runs: fi if [ "${{ inputs.include-c7n-org }}" == true ]; then pip install c7n-org - export PATH=~/.local/bin/:$PATH + sudo ln -s "$(pwd)/.local/bin/c7n-org" /usr/local/bin/c7n-org fi dir=$(pwd) cat << EOF > /usr/local/bin/custodian From c9654d5e8b89bbc67f1bba50142761747f65bb6b Mon Sep 17 00:00:00 2001 From: Gregory Schofield Date: Wed, 22 Jun 2022 12:34:37 -0400 Subject: [PATCH 4/8] Use a custom executable script file for c7n-org Signed-off-by: Gregory Schofield --- action.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index aaec464..4ace29b 100644 --- a/action.yml +++ b/action.yml @@ -35,10 +35,6 @@ runs: if [ "${{ inputs.include-gcp }}" == true ]; then pip install c7n_gcp fi - if [ "${{ inputs.include-c7n-org }}" == true ]; then - pip install c7n-org - sudo ln -s "$(pwd)/.local/bin/c7n-org" /usr/local/bin/c7n-org - fi dir=$(pwd) cat << EOF > /usr/local/bin/custodian #!/bin/bash @@ -46,3 +42,12 @@ runs: custodian "\$@" EOF chmod +x /usr/local/bin/custodian + if [ "${{ inputs.include-c7n-org }}" == true ]; then + pip install c7n-org + dir=$(pwd) + cat << EOF > /usr/local/bin/c7n-org + #!/bin/bash + ${dir}/.local/bin/c7n-org "\$@" + EOF + chmod +x /usr/local/bin/c7n-org + fi From b909d60afdd5850f9499a392b6c6a34ca8b6c513 Mon Sep 17 00:00:00 2001 From: Gregory Schofield Date: Wed, 22 Jun 2022 12:38:43 -0400 Subject: [PATCH 5/8] :angry: Signed-off-by: Gregory Schofield --- action.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 4ace29b..3086824 100644 --- a/action.yml +++ b/action.yml @@ -35,6 +35,7 @@ runs: if [ "${{ inputs.include-gcp }}" == true ]; then pip install c7n_gcp fi + dir=$(pwd) cat << EOF > /usr/local/bin/custodian #!/bin/bash @@ -42,12 +43,13 @@ runs: custodian "\$@" EOF chmod +x /usr/local/bin/custodian + if [ "${{ inputs.include-c7n-org }}" == true ]; then pip install c7n-org - dir=$(pwd) + dir=$(echo ~) cat << EOF > /usr/local/bin/c7n-org - #!/bin/bash - ${dir}/.local/bin/c7n-org "\$@" - EOF + #!/bin/bash + ${dir}/.local/bin/c7n-org "\$@" + EOF chmod +x /usr/local/bin/c7n-org fi From 2c103e41f0fd02e6125419bdf6a1ff27616eca69 Mon Sep 17 00:00:00 2001 From: Gregory Schofield Date: Wed, 22 Jun 2022 13:37:20 -0400 Subject: [PATCH 6/8] Refactor action into multiple run steps Signed-off-by: Gregory Schofield --- action.yml | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/action.yml b/action.yml index 3086824..ef44f99 100644 --- a/action.yml +++ b/action.yml @@ -20,7 +20,8 @@ inputs: runs: using: "composite" steps: - - shell: "bash" + - name: "Install cloud custodian" + shell: "bash" run: | python3 -m venv custodian source custodian/bin/activate @@ -29,13 +30,6 @@ runs: VERSION_ARG="== ${{ inputs.custodian-version }}" fi pip install -Iv c7n"${VERSION_ARG}" - if [ "${{ inputs.include-azure }}" == true ]; then - pip install c7n_azure - fi - if [ "${{ inputs.include-gcp }}" == true ]; then - pip install c7n_gcp - fi - dir=$(pwd) cat << EOF > /usr/local/bin/custodian #!/bin/bash @@ -44,12 +38,31 @@ runs: EOF chmod +x /usr/local/bin/custodian - if [ "${{ inputs.include-c7n-org }}" == true ]; then - pip install c7n-org - dir=$(echo ~) - cat << EOF > /usr/local/bin/c7n-org + - name: "Install azure extension" + if: inputs.include-azure == true + shell: "bash" + run: | + source custodian/bin/activate + pip install c7n_azure + + - name: "Install gcp extension" + if: inputs.include-gcp == true + shell: "bash" + run: | + source custodian/bin/activate + pip install c7n_gcp + + - name: "Install c7n-org extension" + if: inputs.include-c7n-org == true + shell: "bash" + run: | + source custodian/bin/activate + pip install c7n-org + dir=$(pwd) + cat << EOF > /usr/local/bin/c7n-org #!/bin/bash - ${dir}/.local/bin/c7n-org "\$@" + source ${dir}/custodian/bin/activate + c7n-org "\$@" EOF - chmod +x /usr/local/bin/c7n-org - fi + chmod +x /usr/local/bin/c7n-org + \ No newline at end of file From 1fa507159576d8795f585aa0525cb9d692ba29b3 Mon Sep 17 00:00:00 2001 From: Gregory Schofield Date: Wed, 22 Jun 2022 13:39:57 -0400 Subject: [PATCH 7/8] Install quietly Signed-off-by: Gregory Schofield --- action.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index ef44f99..68b5e55 100644 --- a/action.yml +++ b/action.yml @@ -29,7 +29,7 @@ runs: if [ "${{ inputs.custodian-version }}" ]; then VERSION_ARG="== ${{ inputs.custodian-version }}" fi - pip install -Iv c7n"${VERSION_ARG}" + pip install --quiet -Iv c7n"${VERSION_ARG}" dir=$(pwd) cat << EOF > /usr/local/bin/custodian #!/bin/bash @@ -43,21 +43,21 @@ runs: shell: "bash" run: | source custodian/bin/activate - pip install c7n_azure + pip install --quiet c7n_azure - name: "Install gcp extension" if: inputs.include-gcp == true shell: "bash" run: | source custodian/bin/activate - pip install c7n_gcp + pip install --quiet c7n_gcp - name: "Install c7n-org extension" if: inputs.include-c7n-org == true shell: "bash" run: | source custodian/bin/activate - pip install c7n-org + pip install --quiet c7n-org dir=$(pwd) cat << EOF > /usr/local/bin/c7n-org #!/bin/bash @@ -65,4 +65,3 @@ runs: c7n-org "\$@" EOF chmod +x /usr/local/bin/c7n-org - \ No newline at end of file From abae958e057345faf4551ec0db10bd1a43264f83 Mon Sep 17 00:00:00 2001 From: Gregory Schofield Date: Wed, 22 Jun 2022 13:41:43 -0400 Subject: [PATCH 8/8] Update if syntax Signed-off-by: Gregory Schofield --- action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 68b5e55..c6e3eb1 100644 --- a/action.yml +++ b/action.yml @@ -39,21 +39,21 @@ runs: chmod +x /usr/local/bin/custodian - name: "Install azure extension" - if: inputs.include-azure == true + if: ${{ inputs.include-azure }} shell: "bash" run: | source custodian/bin/activate pip install --quiet c7n_azure - name: "Install gcp extension" - if: inputs.include-gcp == true + if: ${{ inputs.include-gcp }} shell: "bash" run: | source custodian/bin/activate pip install --quiet c7n_gcp - name: "Install c7n-org extension" - if: inputs.include-c7n-org == true + if: ${{ inputs.include-c7n-org }} shell: "bash" run: | source custodian/bin/activate