Changing helm-release again

This commit is contained in:
john-westcott-iv
2023-04-19 11:54:25 -04:00
parent d0e30a6878
commit 732ff9c02c
3 changed files with 44 additions and 23 deletions

View File

@@ -12,11 +12,6 @@ jobs:
with: with:
depth: 0 depth: 0
- uses: actions/checkout@v3
with:
ref: gh-pages
path: gh-pages
- name: Log in to GHCR - name: Log in to GHCR
run: | run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin 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 chart_owner=${{ github.repository_owner }} \
-e tag=${{ github.event.release.tag_name }} \ -e tag=${{ github.event.release.tag_name }} \
-e gh_token=${{ secrets.GITHUB_TOKEN }} \ -e gh_token=${{ secrets.GITHUB_TOKEN }} \
-e gh_user=${{ github.actor }} -e gh_user=${{ github.actor }} \
-e repo_type=https

View File

@@ -65,6 +65,7 @@ CHART_DESCRIPTION ?= A Helm chart for the AWX Operator
CHART_OWNER ?= $(GH_REPO_OWNER) CHART_OWNER ?= $(GH_REPO_OWNER)
CHART_REPO ?= awx-operator CHART_REPO ?= awx-operator
CHART_BRANCH ?= gh-pages CHART_BRANCH ?= gh-pages
CHART_DIR ?= gh-pages
CHART_INDEX ?= index.yaml CHART_INDEX ?= index.yaml
.PHONY: all .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 # that is contained within a larger repo, where a tag may not require a new chart version
.PHONY: helm-index .PHONY: helm-index
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 # TODO: test if gh-pages directory exists and if not exist
@echo "== GENERATE INDEX FILE ==" @echo "== GENERATE INDEX FILE =="
@@ -392,6 +393,6 @@ helm-index:
# generate the index file in the root of the gh-pages branch # 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 # --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 # 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

View File

@@ -2,6 +2,8 @@
- hosts: localhost - hosts: localhost
vars: vars:
chart_repo: awx-operator chart_repo: awx-operator
environment:
CHART_OWNER: "{{ chart_owner }}"
tasks: tasks:
- name: Look up release - name: Look up release
uri: uri:
@@ -66,26 +68,48 @@
- when: commits_for_release.stdout == '' - when: commits_for_release.stdout == ''
block: block:
- name: Configure git config - name: Make a temp dir
shell: | tempfile:
git config user.name {{ gh_user }} state: directory
git config user.email {{ gh_user }}@users.noreply.github.com register: temp_dir
args:
chdir: "{{ playbook_dir }}/../gh-pages" - 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 - name: Publish helm index
command: | ansible.builtin.command:
make helm-index cmd: make helm-index
environment: environment:
CHART_OWNER: "{{ chart_owner }}" CHART_OWNER: "{{ chart_owner }}"
CR_TOKEN: "{{ gh_token }}" CR_TOKEN: "{{ gh_token }}"
CHART_DIR: "{{ temp_dir.path }}"
args: args:
chdir: "{{ playbook_dir }}/../" chdir: "{{ playbook_dir }}/.."
- name: Stage and Push commit to gh-pages branch - name: Stage and Push commit to gh-pages branch
shell: | command:
git add index.yaml cmd: "{{ item }}"
git commit -m "{{ commit_message }}" loop:
git push - git add index.yaml
- git commit -m "{{ commit_message }}"
#- git push
args: 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