bump-latest-cdk8s-plus-library #84
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". | |
name: bump-latest-cdk8s-plus-library | |
on: | |
workflow_dispatch: | |
inputs: | |
testing_mode: | |
type: boolean | |
description: Testing Mode | |
required: true | |
default: true | |
schedule: | |
- cron: 0 18 * * 0 | |
jobs: | |
check-latest-k8s-release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
outputs: | |
latestVersion: ${{ steps.k8s-latest-version.outputs.latestVersion }} | |
currentVersion: ${{ steps.k8s-current-version.outputs.currentVersion }} | |
httpStatus: ${{ steps.get-npm-status-code.outputs.httpStatus }} | |
steps: | |
- name: Get latest K8s Release | |
id: get-k8s-latest-release | |
uses: pozetroninc/github-action-get-latest-release@master | |
with: | |
repository: kubernetes/kubernetes | |
excludes: prerelease, draft | |
- name: Get latest K8s minor version | |
id: k8s-latest-version | |
run: echo latestVersion="$(cut -d "." -f 2 <<< "${{ steps.get-k8s-latest-release.outputs.release }}")" >> $GITHUB_OUTPUT | |
- name: Get previous K8s minor version | |
id: k8s-current-version | |
run: echo currentVersion=$(( ${{ steps.k8s-latest-version.outputs.latestVersion }} - 1 )) >> $GITHUB_OUTPUT | |
- name: Check to see if cdk8s-plus released latest k8s version on npm by getting HTTP status code from npm url | |
id: get-npm-status-code | |
run: |- | |
echo httpStatus="$(curl -sL -w "%{http_code} | |
" "https://www.npmjs.com/package/cdk8s-plus-${{steps.k8s-latest-version.outputs.latestVersion}}" -o /dev/null)" >> $GITHUB_OUTPUT | |
generate-new-k8s-spec: | |
needs: check-latest-k8s-release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
if: needs.check-latest-k8s-release.outputs.httpStatus != 200 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 18.12.0 | |
- name: Install dependencies | |
run: yarn install --check-files | |
- name: Generate Kubernetes schema | |
env: | |
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
run: ${{ github.workspace }}/tools/import-spec.sh 1.${{ needs.check-latest-k8s-release.outputs.latestVersion }}.0 | |
continue-on-error: false | |
- name: Set auto-approve label for PR if in testing mode | |
id: set-auto-approve-label | |
if: ${{ github.event.inputs.testingMode }} == false | |
env: | |
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
run: echo labels="auto-approve" >> $GITHUB_OUTPUT | |
continue-on-error: false | |
- name: Create Pull Request | |
id: create-pr | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
commit-message: |- | |
chore: v${{ needs.check-latest-k8s-release.outputs.latestVersion }} kubernetes-spec | |
This PR is adds the v${{ needs.check-latest-k8s-release.outputs.latestVersion }} Kubernetes spec. This is required in order for us to add a new version to cdk8s-plus. See details in [workflow run]. | |
[Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
------ | |
*Automatically created by projen via the "create-pull-request" workflow* | |
branch: github-actions/generate-k8s-spec-${{ needs.check-latest-k8s-release.outputs.latestVersion }} | |
title: "chore: v${{ needs.check-latest-k8s-release.outputs.latestVersion }} kubernetes-spec" | |
labels: ${{ steps.set-auto-approve-label.outputs.labels }} | |
body: |- | |
This PR is adds the v${{ needs.check-latest-k8s-release.outputs.latestVersion }} Kubernetes spec. This is required in order for us to add a new version to cdk8s-plus. See details in [workflow run]. | |
[Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
------ | |
*Automatically created by projen via the "create-pull-request" workflow* | |
author: github-actions <[email protected]> | |
committer: github-actions <[email protected]> | |
signoff: true | |
add-backport-label: | |
needs: check-latest-k8s-release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
if: needs.check-latest-k8s-release.outputs.httpStatus != 200 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
repository: cdk8s-team/cdk8s-plus | |
- name: Create new backport label for old version | |
uses: actions-ecosystem/action-add-labels@v1 | |
with: | |
labels: backport-to-k8s-${{ needs.check-latest-k8s-release.outputs.currentVersion }}/main | |
repo: cdk8s-team/cdk8s-plus | |
create-new-plus-branch: | |
needs: | |
- check-latest-k8s-release | |
- generate-new-k8s-spec | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
repository: cdk8s-team/cdk8s-plus | |
- name: Create new branch | |
env: | |
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
run: git checkout -b k8s-${{ needs.check-latest-k8s-release.outputs.latestVersion}}/main | |
continue-on-error: false | |
- name: Update reference of latest cdk8s version in txt file | |
env: | |
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
run: echo "${{ needs.check-latest-k8s-release.outputs.latestVersion }}" >> ${{ github.workspace }}/projenrc/latest-k8s-version.txt | |
continue-on-error: false | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 18.12.0 | |
- name: Install dependencies | |
run: yarn install --check-files | |
- name: Import the new k8s spec from the prerequisite step | |
run: yarn run import | |
- name: Disable publishing if testingMode is true | |
if: ${{ github.event.inputs.testingMode }} == true | |
run: npx projen disable-publishing | |
- name: Test package json output | |
run: cat package.json | |
- name: Let projen update the remaining files | |
run: npx projen build | |
- name: Update references of old kubernetes versions with projen task | |
env: | |
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
run: npx projen update-k8s-version-references | |
continue-on-error: false | |
- name: Push the branch and verify that automation builds/tags/releases the new version successfully. | |
env: | |
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
run: git push --set-upstream origin k8s-${{ needs.check-latest-k8s-release.outputs.latestVersion }}/main | |
continue-on-error: false | |
- name: Create a p0 issue to set the new default branch of the cdk8s-plus repo | |
uses: actions-ecosystem/action-create-issue@v1 | |
with: | |
github_token: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
title: "chore: set default branch of cdk8s-plus repo to latest for v${{ needs.check-latest-k8s-release.outputs.latestVersion }} k8s upgrade" | |
body: The default branch must be manually set to k8s-${{ needs.check-latest-k8s-release.outputs.latestVersion }}/main | |
labels: priority/p0 | |
update-cdk8s-website: | |
needs: | |
- check-latest-k8s-release | |
- create-new-plus-branch | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
if: needs.check-latest-k8s-release.outputs.httpStatus != 200 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Create new branch | |
uses: peterjgrainger/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
with: | |
branch: cdk8s-upgrade/v${{ needs.check-latest-k8s-release.outputs.latestVersion }} | |
sha: ${{ github.event.pull_request.head.sha }} | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 18.12.0 | |
- name: Install dependencies | |
run: yarn install --check-files | |
- name: Update references to newest k8s version in cdk8s repo | |
env: | |
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
run: npx projen replace-old-version-references | |
continue-on-error: false | |
- name: Set auto-approve label for PR if in testing mode | |
id: set-auto-approve-label | |
if: ${{ github.event.inputs.testingMode }} == false | |
env: | |
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
run: echo labels="auto-approve" >> $GITHUB_OUTPUT | |
continue-on-error: false | |
- name: Create Pull Request | |
id: create-pr | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
commit-message: |- | |
chore(website): cdk8s-plus-${{ needs.check-latest-k8s-release.outputs.latestVersion }} | |
This PR updates the website with the latest version of cdk8s-plus. See details in [workflow run]. | |
[Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
------ | |
*Automatically created by projen via the "create-pull-request" workflow* | |
branch: github-actions/website-update-${{ needs.check-latest-k8s-release.outputs.latestVersion }} | |
title: "chore(website): cdk8s-plus-${{ needs.check-latest-k8s-release.outputs.latestVersion }}" | |
labels: ${{ steps.set-auto-approve-label.outputs.labels }} | |
body: |- | |
This PR updates the website with the latest version of cdk8s-plus. See details in [workflow run]. | |
[Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
------ | |
*Automatically created by projen via the "create-pull-request" workflow* | |
author: github-actions <[email protected]> | |
committer: github-actions <[email protected]> | |
signoff: true | |
update-cdk-ops: | |
needs: | |
- check-latest-k8s-release | |
- update-cdk8s-website | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
repository: cdk8s-team/cdk-ops | |
- name: Update latest cdk8s-plus version in cdk-ops repo | |
env: | |
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
run: echo "${{ needs.check-latest-k8s-release.outputs.latestVersion }}" >> ${{ github.workspace }}/projenrc/latest-cdk8s-version.txt | |
continue-on-error: false | |
- name: Set auto-approve label for PR if in testing mode | |
id: set-auto-approve-label | |
if: ${{ github.event.inputs.testingMode }} == false | |
env: | |
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
run: echo labels="auto-approve" >> $GITHUB_OUTPUT | |
continue-on-error: false | |
- name: Create Pull Request | |
id: create-pr | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: ${{ secrets.PROJEN_GITHUB_TOKEN }} | |
commit-message: |- | |
chore: updating latest cdk8s-plus version to v${{ needs.check-latest-k8s-release.outputs.latestVersion }} | |
This PR updates the reference to of the latest cdk8s-plus version. See details in [workflow run]. | |
[Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
------ | |
*Automatically created by projen via the "create-pull-request" workflow* | |
branch: github-actions/cdk-ops-k8s-upgrade-${{ needs.check-latest-k8s-release.outputs.latestVersion }} | |
title: "chore: updating latest cdk8s-plus version to v${{ needs.check-latest-k8s-release.outputs.latestVersion }}" | |
labels: ${{ steps.set-auto-approve-label.outputs.labels }} | |
body: |- | |
This PR updates the reference to of the latest cdk8s-plus version. See details in [workflow run]. | |
[Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
------ | |
*Automatically created by projen via the "create-pull-request" workflow* | |
author: github-actions <[email protected]> | |
committer: github-actions <[email protected]> | |
signoff: true |