mirror of
https://github.com/ansible/awx-operator.git
synced 2026-03-26 21:33:14 +00:00
92 lines
2.9 KiB
YAML
92 lines
2.9 KiB
YAML
---
|
|
- hosts: localhost
|
|
vars:
|
|
chart_repo: awx-operator
|
|
tasks:
|
|
- name: Look up release
|
|
uri:
|
|
url: "https://api.github.com/repos/{{ chart_owner }}/{{ chart_repo }}/releases/tags/{{ tag }}"
|
|
register: release
|
|
ignore_errors: yes
|
|
|
|
- fail:
|
|
msg: |
|
|
Release must exist before running this playbook
|
|
when: release is not success
|
|
|
|
- name: Set helm filename and commit message
|
|
set_fact:
|
|
asset_already_attached: False
|
|
helm_file_name: "awx-operator-{{ tag }}.tgz"
|
|
commit_message: "Updated index.yaml for release {{ release.json.tag_name }}"
|
|
|
|
- name: See if file is already attached
|
|
set_fact:
|
|
asset_already_attached: True
|
|
loop: "{{ release.json.get('assets', []) }}"
|
|
loop_control:
|
|
label: "{{ item.name }}"
|
|
when: item.name == helm_file_name
|
|
|
|
- when: not asset_already_attached
|
|
block:
|
|
- name: Build and package helm chart
|
|
command: |
|
|
make helm-package
|
|
environment:
|
|
VERSION: "{{ tag }}"
|
|
IMAGE_TAG_BASE: "{{ operator_image }}"
|
|
args:
|
|
chdir: "{{ playbook_dir }}/../"
|
|
|
|
# Move to chart releaser after https://github.com/helm/chart-releaser/issues/122 exists
|
|
- name: Upload helm chart
|
|
uri:
|
|
url: "https://uploads.github.com/repos/{{ chart_owner }}/{{ chart_repo }}/releases/{{ release.json.id }}/assets?name={{ helm_file_name }}"
|
|
src: "{{ playbook_dir }}/../.cr-release-packages/awx-operator-{{ tag }}.tgz"
|
|
headers:
|
|
Authorization: "token {{ gh_token }}"
|
|
Content-Type: "application/octet-stream"
|
|
status_code:
|
|
- 200
|
|
- 201
|
|
register: asset_upload
|
|
changed_when: asset_upload.json.state == "uploaded"
|
|
|
|
- name: Ensure gh-pages exists
|
|
file:
|
|
state: directory
|
|
path: "{{ playbook_dir }}/../gh-pages"
|
|
|
|
- name: Check if we have published the release
|
|
command:
|
|
cmd: "git log --grep='{{ commit_message }}'"
|
|
chdir: "{{ playbook_dir }}/../gh-pages"
|
|
register: commits_for_release
|
|
|
|
- when: commits_for_release.stdout == ''
|
|
block:
|
|
- name: Configure git config
|
|
shell: |
|
|
git config user.name {{ gh_user }}
|
|
git config user.email {{ gh_user }}@users.noreply.github.com
|
|
args:
|
|
chdir: "{{ playbook_dir }}/../gh-pages"
|
|
|
|
- name: Publish helm index
|
|
command: |
|
|
make helm-index
|
|
environment:
|
|
CHART_OWNER: "{{ chart_owner }}"
|
|
CR_TOKEN: "{{ gh_token }}"
|
|
args:
|
|
chdir: "{{ playbook_dir }}/../"
|
|
|
|
- name: Stage and Push commit to gh-pages branch
|
|
shell: |
|
|
git add index.yaml
|
|
git commit -m "{{ commit_message }}"
|
|
git push
|
|
args:
|
|
chdir: "{{ playbook_dir }}/../gh-pages"
|