Skip to content

Commit f3caab2

Browse files
authored
ci: pointing to correct versioned yaml on website creation (#3258)
Signed-off-by: Jaydip Gabani <gabanijaydip@gmail.com>
1 parent 7ed8ef0 commit f3caab2

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

.github/workflows/patch-docs.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: patch_docs
2+
on:
3+
push:
4+
tags:
5+
- 'v[0-9]+.[0-9]+.[1-9]+' # run this workflow when a new patch version is published
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
patch-docs:
13+
runs-on: ubuntu-22.04
14+
steps:
15+
- name: Harden Runner
16+
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
17+
with:
18+
egress-policy: audit
19+
20+
- name: Set release version and target branch for vNext
21+
if: github.event_name == 'push'
22+
run: |
23+
TAG="$(echo "${{ github.ref }}" | tr -d 'refs/tags/v')"
24+
MAJOR_VERSION="$(echo "${TAG}" | cut -d '.' -f1)"
25+
echo "MAJOR_VERSION=${MAJOR_VERSION}" >> ${GITHUB_ENV}
26+
MINOR_VERSION="$(echo "${TAG}" | cut -d '.' -f2)"
27+
echo "MINOR_VERSION=${MINOR_VERSION}" >> ${GITHUB_ENV}
28+
PATCH_VERSION="$(echo "${TAG}" | cut -d '.' -f3)"
29+
echo "PATCH_VERSION=${PATCH_VERSION}" >> ${GITHUB_ENV}
30+
echo "TAG=${TAG}" >> ${GITHUB_ENV}
31+
32+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Create release branch if needed # patched docs are always being merged to the master branch
37+
run: |
38+
git checkout master
39+
40+
- name: Create patch version docs
41+
run: make patch-version-docs NEWVERSION=v${MAJOR_VERSION}.${MINOR_VERSION}.x TAG=v${TAG} OLDVERSION=v${MAJOR_VERSION}.${MINOR_VERSION}.$((PATCH_VERSION-1))
42+
43+
- name: Create release pull request
44+
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2
45+
with:
46+
commit-message: "chore: Patch docs for ${{ env.TAG }} release"
47+
title: "chore: Patch docs for ${{ env.TAG }} release"
48+
branch: "patch-docs-${{ env.TAG }}"
49+
base: "master"
50+
signoff: true
51+
labels: |
52+
release-pr
53+
${{ github.event.inputs.release_version }}
54+

.github/workflows/release-pr.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
echo "NEWVERSION=v${MAJOR_VERSION}.$((MINOR_VERSION+1)).0-beta.0" >> ${GITHUB_ENV}
4242
# pre-release is always being merged to the master branch
4343
echo "TARGET_BRANCH=master" >> ${GITHUB_ENV}
44+
echo "TAG=${TAG}" >> ${GITHUB_ENV}
4445
4546
- name: Set release version and target branch from input
4647
if: github.event_name == 'workflow_dispatch'
@@ -49,6 +50,7 @@ jobs:
4950
echo "${NEWVERSION}" | grep -E '^v[0-9]+\.[0-9]+\.[0-9](-(beta|rc)\.[0-9]+)?$' || (echo "release_version should be in the format vX.Y.Z, vX.Y.Z-beta.A, or vX.Y.Z-rc.B" && exit 1)
5051
5152
echo "NEWVERSION=${NEWVERSION}" >> ${GITHUB_ENV}
53+
echo "TAG=${NEWVERSION}" >> ${GITHUB_ENV}
5254
MAJOR_VERSION="$(echo "${NEWVERSION}" | cut -d '.' -f1 | tr -d 'v')"
5355
MINOR_VERSION="$(echo "${NEWVERSION}" | cut -d '.' -f2)"
5456
@@ -75,7 +77,7 @@ jobs:
7577
- run: make release-manifest promote-staging-manifest
7678

7779
- if: github.event_name == 'push'
78-
run: make version-docs NEWVERSION=v${MAJOR_VERSION}.${MINOR_VERSION}.x
80+
run: make version-docs NEWVERSION=v${MAJOR_VERSION}.${MINOR_VERSION}.x TAG=v${TAG}
7981

8082
- name: Create release pull request
8183
uses: peter-evans/create-pull-request@b1ddad2c994a25fbc81a28b3ec0e368bb2021c50 # v6.0.0

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ release-manifest:
475475
@sed -i "s/tag: $(VERSION)/tag: ${NEWVERSION}/" ./cmd/build/helmify/static/values.yaml
476476
@sed -i 's/Current release version: `$(VERSION)`/Current release version: `'"${NEWVERSION}"'`/' ./cmd/build/helmify/static/README.md
477477
@sed -i -e 's/^VERSION := $(VERSION)/VERSION := ${NEWVERSION}/' ./Makefile
478-
@sed -i 's/https:\/\/raw\.githubusercontent\.com\/open-policy-agent\/gatekeeper\/master\/deploy\/gatekeeper\.yaml.*/https:\/\/raw\.githubusercontent\.com\/open-policy-agent\/gatekeeper\/${NEWVERSION}\/deploy\/gatekeeper\.yaml/' ./website/docs/install.md
479478
export
480479
$(MAKE) manifests
481480

@@ -488,6 +487,11 @@ version-docs:
488487
-u $(shell id -u):$(shell id -g) \
489488
node:${NODE_VERSION} \
490489
sh -c "yarn install --frozen-lockfile && yarn run docusaurus docs:version ${NEWVERSION}"
490+
@sed -i 's/https:\/\/raw\.githubusercontent\.com\/open-policy-agent\/gatekeeper\/master\/deploy\/gatekeeper\.yaml.*/https:\/\/raw\.githubusercontent\.com\/open-policy-agent\/gatekeeper\/${TAG}\/deploy\/gatekeeper\.yaml/' ./website/versioned_docs/version-${NEWVERSION}/install.md
491+
492+
.PHONY: patch-version-docs
493+
patch-version-docs:
494+
@sed -i 's/https:\/\/raw\.githubusercontent\.com\/open-policy-agent\/gatekeeper\/${OLDVERSION}\/deploy\/gatekeeper\.yaml.*/https:\/\/raw\.githubusercontent\.com\/open-policy-agent\/gatekeeper\/${TAG}\/deploy\/gatekeeper\.yaml/' ./website/versioned_docs/version-${NEWVERSION}/install.md
491495

492496
promote-staging-manifest:
493497
@rm -rf deploy

0 commit comments

Comments
 (0)