From 732ff9c02cf89aee91d3cedbdde97769eda492a5 Mon Sep 17 00:00:00 2001 From: john-westcott-iv Date: Wed, 19 Apr 2023 11:54:25 -0400 Subject: [PATCH] Changing helm-release again --- .github/workflows/promote.yaml | 8 ++---- Makefile | 7 +++-- ansible/helm-release.yml | 52 +++++++++++++++++++++++++--------- 3 files changed, 44 insertions(+), 23 deletions(-) diff --git a/.github/workflows/promote.yaml b/.github/workflows/promote.yaml index f1883971..93c70ef9 100644 --- a/.github/workflows/promote.yaml +++ b/.github/workflows/promote.yaml @@ -12,11 +12,6 @@ jobs: with: depth: 0 - - uses: actions/checkout@v3 - with: - ref: gh-pages - path: gh-pages - - name: Log in to GHCR run: | echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin @@ -40,4 +35,5 @@ jobs: -e chart_owner=${{ github.repository_owner }} \ -e tag=${{ github.event.release.tag_name }} \ -e gh_token=${{ secrets.GITHUB_TOKEN }} \ - -e gh_user=${{ github.actor }} + -e gh_user=${{ github.actor }} \ + -e repo_type=https diff --git a/Makefile b/Makefile index e0e1257d..5995f5fb 100644 --- a/Makefile +++ b/Makefile @@ -65,6 +65,7 @@ CHART_DESCRIPTION ?= A Helm chart for the AWX Operator CHART_OWNER ?= $(GH_REPO_OWNER) CHART_REPO ?= awx-operator CHART_BRANCH ?= gh-pages +CHART_DIR ?= gh-pages CHART_INDEX ?= index.yaml .PHONY: all @@ -364,7 +365,7 @@ TAGS := $(shell git ls-remote --tags --sort=version:refname --refs -q | cut -d/ # that is contained within a larger repo, where a tag may not require a new chart version .PHONY: helm-index helm-index: - # when running in CI this gh-pages are already checked out with github action to 'gh-pages' directory + # when running in CI the gh-pages branch is checked out by the ansible playbook # TODO: test if gh-pages directory exists and if not exist @echo "== GENERATE INDEX FILE ==" @@ -392,6 +393,6 @@ helm-index: # generate the index file in the root of the gh-pages branch # --merge will leave any values in index.yaml that don't get generated by this command, but # it is likely that all values are overridden - $(HELM) repo index .cr-release-packages --url https://github.com/$(CHART_OWNER)/$(CHART_REPO)/releases/download/ --merge gh-pages/index.yaml + $(HELM) repo index .cr-release-packages --url https://github.com/$(CHART_OWNER)/$(CHART_REPO)/releases/download/ --merge $(CHART_DIR)/index.yaml - mv .cr-release-packages/index.yaml gh-pages/index.yaml + mv .cr-release-packages/index.yaml $(CHART_DIR)/index.yaml diff --git a/ansible/helm-release.yml b/ansible/helm-release.yml index a2a37bf2..ef6022ed 100644 --- a/ansible/helm-release.yml +++ b/ansible/helm-release.yml @@ -2,6 +2,8 @@ - hosts: localhost vars: chart_repo: awx-operator + environment: + CHART_OWNER: "{{ chart_owner }}" tasks: - name: Look up release uri: @@ -66,26 +68,48 @@ - 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: Make a temp dir + tempfile: + state: directory + register: temp_dir + + - name: Clone the gh-pages branch from {{ chart_owner }} + git: + repo: "{{ ((repo_type | default('http')) == 'ssh') | ternary(ssh_repo, http_repo) }}" + dest: "{{ temp_dir.path }}" + single_branch: yes + version: gh-pages + vars: + http_repo: "https://github.com/{{ chart_owner }}/{{ chart_repo }}" + ssh_repo: "git@github.com:{{ chart_owner }}/{{ chart_repo }}.git" - name: Publish helm index - command: | - make helm-index + ansible.builtin.command: + cmd: make helm-index environment: CHART_OWNER: "{{ chart_owner }}" CR_TOKEN: "{{ gh_token }}" + CHART_DIR: "{{ temp_dir.path }}" args: - chdir: "{{ playbook_dir }}/../" + chdir: "{{ playbook_dir }}/.." - name: Stage and Push commit to gh-pages branch - shell: | - git add index.yaml - git commit -m "{{ commit_message }}" - git push + command: + cmd: "{{ item }}" + loop: + - git add index.yaml + - git commit -m "{{ commit_message }}" + #- git push args: - chdir: "{{ playbook_dir }}/../gh-pages" + chdir: "{{ temp_dir.path }}/" + environment: + GIT_AUTHOR_NAME: "{{ gh_user }}" + GIT_AUTHOR_EMAIL: "{{ gh_user }}@users.noreply.github.com" + GIT_COMMITTER_NAME: "{{ gh_user }}" + GIT_COMMITTER_EMAIL: "{{ gh_user }}@users.noreply.github.com" + + always: + - name: Remove temp dir + file: + path: "{{ temp_dir.path }}" + state: absent