Skip to content

Commit

Permalink
Improve find_github_artifact role
Browse files Browse the repository at this point in the history
  • Loading branch information
jvasseur committed Apr 3, 2024
1 parent 9d4fa47 commit 66f779b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions deploy_artifact/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
artifact_headers: {}
artifact_url: ~
shared_paths: []
before_finalize: []
Expand Down
22 changes: 17 additions & 5 deletions find_github_artifact/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
accept: application/vnd.github+json
authorization: Bearer {{ github_token }}
x-github-api-version: '2022-11-28'
check_mode: false
register: commits

- name: Get commit
Expand All @@ -19,13 +20,14 @@
accept: application/vnd.github+json
authorization: Bearer {{ github_token }}
x-github-api-version: '2022-11-28'
check_mode: false
register: workflows

- name: Get workflow
ansible.builtin.set_fact:
workflow: '{{ workflows.json | community.general.json_query(query) }}'
vars:
query: 'workflows[?path==`.github/workflows/{{ workflow_name }}.yaml`] | [0]'
query: 'workflows[?path==`.github/workflows/{{ workflow_file }}`] | [0]'

- name: Fetch runs
ansible.builtin.uri:
Expand All @@ -34,6 +36,7 @@
accept: application/vnd.github+json
authorization: Bearer {{ github_token }}
x-github-api-version: '2022-11-28'
check_mode: false
register: runs

- name: Get run
Expand All @@ -47,16 +50,25 @@
accept: application/vnd.github+json
authorization: Bearer {{ github_token }}
x-github-api-version: '2022-11-28'
check_mode: false
register: artifacts

- name: Get artifact
ansible.builtin.set_fact:
artifact: '{{ artifacts.json.artifacts[0] }}'

- name: Set variables
ansible.builtin.set_fact:
artifact_url: '{{ artifact.archive_download_url }}'
artifact_headers:
- name: Get the download URL of the artifact
ansible.builtin.uri:
url: '{{ artifact.archive_download_url }}'
follow_redirects: no

Check failure on line 63 in find_github_artifact/tasks/main.yaml

View workflow job for this annotation

GitHub Actions / Ansible Lint

yaml[truthy]

Truthy value should be one of \[false, true]
headers:
accept: application/vnd.github+json
authorization: Bearer {{ github_token }}
x-github-api-version: '2022-11-28'
status_code:
- 302
register: artifact_download

- name: Set variables
ansible.builtin.set_fact:
artifact_url: '{{ artifact_download.location }}'

0 comments on commit 66f779b

Please sign in to comment.