diff --git a/.github/workflows/README.md b/.github/workflows/README.md index b65816ea..342afbda 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -22,3 +22,7 @@ Second improvement was to wrap this `make go-generate` into a GitHub Actions wor * Automatically triggered via API In rancher/kontainer-driver-metadata, we added a `dispatch` step in `.drone.yml`, which will execute this GitHub Actions workflow after a PR is merged. The user that merged the PR will also be mentioned and assigned in the PR that will be created when this workflow has finished. + +## Update README (`update-readme.yml`) + +This workflow will update the README with latest versions retrieved from tags in the GitHub repository. It uses the file `README-template.md` as source, and will add the latest versions into this file to end up with the actual `README.md` file. diff --git a/.github/workflows/update-readme.yml b/.github/workflows/update-readme.yml new file mode 100644 index 00000000..b3ef8f27 --- /dev/null +++ b/.github/workflows/update-readme.yml @@ -0,0 +1,73 @@ +name: Update README +on: workflow_dispatch + +permissions: + contents: write + pull-requests: write + +jobs: + update-readme: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Update README file + run: | + tmpfile=$(mktemp) + latest13=$(curl -sL https://api.github.com/repos/rancher/rke/tags?per_page=1000 | jq -r 'first(.[] | select(.name | startswith("v1.3")) | select(.name | contains("rc") | not) | .name)') + latest12=$(curl -sL https://api.github.com/repos/rancher/rke/tags?per_page=1000 | jq -r 'first(.[] | select(.name | startswith("v1.2")) | select(.name | contains("rc") | not) | .name)') + echo "* v1.3" > $tmpfile + echo " * ${latest13} - Read the full release [notes](https://github.com/rancher/rke/releases/tag/${latest13})." >> $tmpfile + echo "* v1.2" >> $tmpfile + echo " * ${latest12} - Read the full release [notes](https://github.com/rancher/rke/releases/tag/${latest12})." >> $tmpfile + sed -e '/## Latest Release/r '"$tmpfile"'' -e 's/CURRENTYEAR/'"$(date +%Y)"'/g' README-template.md > README.md + - name: Check for repository changes + run: | + if git diff --name-only --exit-code; then + echo "No changes found in repository after updating README" + echo "changes_exist=false" >> $GITHUB_ENV + else + echo "Changes found in repository after updating README:" + git diff --name-only + echo "changes_exist=true" >> $GITHUB_ENV + fi + - name: Create branch, commit and push + if: ${{ env.changes_exist == 'true' }} + id: branch + run: | + BRANCH="githubaction-update-readme-$(date +%Y-%m-%d-%H-%M-%S)" + echo "::set-output name=branch::$BRANCH" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + git checkout -b "$BRANCH" + git commit -a -m "update README with latest" + git push origin "$BRANCH" + - name: Create Pull Request + if: ${{ env.changes_exist == 'true' }} + id: cpr + env: + SOURCE_BRANCH: ${{ steps.branch.outputs.branch }} + uses: actions/github-script@v5.0.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + let body = 'Auto-generated by GitHub Actions' + + const { data: pr } = await github.rest.pulls.create({ + title: `[${{ github.ref_name }}] update README with latest`, + body: body, + owner: context.repo.owner, + repo: context.repo.repo, + base: "${{ github.ref_name }}", + head: `${ process.env.SOURCE_BRANCH }` + }); + await github.rest.issues.addLabels({ + ...context.repo, + issue_number: pr.number, + labels: ["status/auto-created"], + }); + console.log('Created new pull request'); + return pr.html_url; + - name: Check outputs + if: ${{ env.changes_exist == 'true' }} + run: | + echo "Pull Request URL - ${{ steps.cpr.outputs.result }}" diff --git a/README-template.md b/README-template.md new file mode 100644 index 00000000..fb250f1c --- /dev/null +++ b/README-template.md @@ -0,0 +1,69 @@ +# rke + +*This file is auto-generated from README-template.md, please make any changes there.* + +Rancher Kubernetes Engine, an extremely simple, lightning fast Kubernetes installer that works everywhere. + +## Latest Release + +## Download + +Please check the [releases](https://github.com/rancher/rke/releases/) page. + +## Requirements + +Please review the [OS requirements](https://rancher.com/docs/rke/latest/en/os/) for each node in your Kubernetes cluster. + +## Getting Started + +Please refer to our [RKE docs](https://rancher.com/docs/rke/latest/en/) for information on how to get started! +For cluster config examples, refer to [RKE cluster.yml examples](https://rancher.com/docs/rke/latest/en/example-yamls/) + +## Installing Rancher HA using rke + +Please use [High Availability (HA) Install](https://rancher.com/docs/rancher/v2.x/en/installation/ha/) to install Rancher in a high-availability configuration. + +## Building + +RKE can be built using the `make` command, and will use the scripts in the `scripts` directory as subcommands. The default subcommand is `ci` and will use `scripts/ci`. Cross compiling can be enabled by setting the environment variable `CROSS=1`. The compiled binaries can be found in the `build/bin` directory. Dependencies are managed by Go modules and can be found in [go.mod](https://github.com/rancher/rke/blob/master/go.mod). + +RKE now fetches `data.json` from https://github.com/rancher/kontainer-driver-metadata. To fetch data.json and compile it in rke, run + +```bash +go generate + +# Change RANCHER_METADATA_URL to an external URL instead of using https://releases.rancher.com/kontainer-driver-metadata/dev-v2.6/data.json by default +RANCHER_METADATA_URL=${URL} go generate + +# Or load it from local file +RANCHER_METATDATA_URL=./local/data.json go generate + +# Compile RKE +make +``` + +To specify RANCHER_METADATA_URL in runtime, populate the environment variable when running rke CLI. For example: + +```bash +RANCHER_METADATA_URL=${URL} rke [commands] [options] + +RANCHER_METADATA_URL=${./local/data.json} rke [commands] [options] +``` + +`RANCHER_METADATA_URL` defaults to `https://releases.rancher.com/kontainer-driver-metadata/dev-v2.6/data.json`. + +## License + +Copyright (c) CURRENTYEAR [Rancher Labs, Inc.](http://rancher.com) + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.