Skip to content

Commit

Permalink
Install jq version (#12)
Browse files Browse the repository at this point in the history
## what
* Install jq `1.6` 

## why
* Self-hosted runners can have jq version `<1.6` and that breaks the action
  • Loading branch information
goruha authored Nov 2, 2022
1 parent dfae621 commit ad3ac00
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 4 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/test-jq-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Test JQ version
on:
workflow_dispatch: {}
## Added pull_request to register workflow from the PR.
## Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo
# pull_request: {}

jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Setup
run: echo "Do setup"

test:
runs-on: ubuntu-latest
needs: [setup]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: 'Setup jq'
uses: dcarbone/install-jq-action@v1.0.0
with:
version: 1.5
force: 'true'

- name: Downgrade version
id: base
run: |
chmod +x /opt/hostedtoolcache/jq/jq
echo "version=$(jq --version)" >> $GITHUB_OUTPUT
- uses: nick-fields/assert-action@v1
with:
expected: 'jq-1.5'
actual: ${{ steps.base.outputs.version }}

- uses: ./
id: current
with:
env-label: |
preview: deploy
qa1: deploy/qa1
qa2: deploy/qa2
qa3: deploy/qa3
qa4: deploy/qa4
labels: '["deploy","deploy/qa2"]'
open: 'true'

- name: Current version
id: new
run: |
jq --version
echo "version=$(jq --version)" >> $GITHUB_OUTPUT
- uses: nick-fields/assert-action@v1
with:
expected: 'jq-1.6'
actual: ${{ steps.new.outputs.version }}


- uses: nick-fields/assert-action@v1
with:
expected: '["preview","qa2"]'
actual: ${{ steps.current.outputs.deploy_envs }}

- uses: nick-fields/assert-action@v1
with:
expected: '["qa1","qa3","qa4"]'
actual: ${{ steps.current.outputs.destroy_envs }}

teardown:
runs-on: ubuntu-latest
needs: [test]
if: ${{ always() }}
steps:
- name: Tear down
run: echo "Do Tear down"
3 changes: 1 addition & 2 deletions .github/workflows/test-pr-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ on:
workflow_dispatch: {}
## Added pull_request to register workflow from the PR.
## Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo
pull_request:
branches-ignore: ['*']
# pull_request: {}

jobs:
setup:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test-pr-opened.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ on:
workflow_dispatch: {}
## Added pull_request to register workflow from the PR.
## Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo
pull_request:
branches-ignore: ['*']
# pull_request: {}

jobs:
setup:
Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ runs:
echo "::set-output name=destroy::with_entries(select(.value | IN({0}[]))) | keys"
fi
- name: 'Install jq 1.6'
uses: dcarbone/install-jq-action@v1.0.0
with:
version: 1.6
force: 'true'

- name: Fix JQ permissions https://github.com/dcarbone/install-jq-action/pull/1
shell: bash
run: chmod +x /opt/hostedtoolcache/jq/jq

- uses: edwardgeorge/jq-action@main
id: deploy_envs
with:
Expand Down

0 comments on commit ad3ac00

Please sign in to comment.