Merge pull request #3501 from kingdonb/flux-action-updates
Add GITHUB_TOKEN to Flux GitHub Action
This commit is contained in:
@@ -35,6 +35,20 @@ You can download a specific version with:
|
|||||||
version: 0.32.0
|
version: 0.32.0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can also authenticate against the GitHub API using GitHub Actions' `GITHUB_TOKEN` secret.
|
||||||
|
|
||||||
|
For more information, please [read about the GitHub token secret](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret).
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Setup Flux CLI
|
||||||
|
uses: fluxcd/flux2/action@main
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
```
|
||||||
|
|
||||||
|
This is useful if you are seeing failures on shared runners, those failures are usually API limits being hit.
|
||||||
|
|
||||||
### Automate Flux updates
|
### Automate Flux updates
|
||||||
|
|
||||||
Example workflow for updating Flux's components generated with `flux bootstrap --path=clusters/production`:
|
Example workflow for updating Flux's components generated with `flux bootstrap --path=clusters/production`:
|
||||||
@@ -52,7 +66,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Setup Flux CLI
|
- name: Setup Flux CLI
|
||||||
uses: fluxcd/flux2/action@main
|
uses: fluxcd/flux2/action@main
|
||||||
- name: Check for updates
|
- name: Check for updates
|
||||||
@@ -62,9 +76,9 @@ jobs:
|
|||||||
--export > ./clusters/production/flux-system/gotk-components.yaml
|
--export > ./clusters/production/flux-system/gotk-components.yaml
|
||||||
|
|
||||||
VERSION="$(flux -v)"
|
VERSION="$(flux -v)"
|
||||||
echo "::set-output name=flux_version::$VERSION"
|
echo "flux_version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v3
|
uses: peter-evans/create-pull-request@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
branch: update-flux
|
branch: update-flux
|
||||||
@@ -177,7 +191,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Setup Flux CLI
|
- name: Setup Flux CLI
|
||||||
uses: fluxcd/flux2/action@main
|
uses: fluxcd/flux2/action@main
|
||||||
- name: Setup Kubernetes Kind
|
- name: Setup Kubernetes Kind
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ inputs:
|
|||||||
bindir:
|
bindir:
|
||||||
description: "Optional location of the Flux binary. Will not use sudo if set. Updates System Path."
|
description: "Optional location of the Flux binary. Will not use sudo if set. Updates System Path."
|
||||||
required: false
|
required: false
|
||||||
|
token:
|
||||||
|
description: "GitHub Token used to authentication against the API (generally only needed to prevent quota limit errors)"
|
||||||
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
@@ -23,9 +26,14 @@ runs:
|
|||||||
run: |
|
run: |
|
||||||
ARCH=${{ inputs.arch }}
|
ARCH=${{ inputs.arch }}
|
||||||
VERSION=${{ inputs.version }}
|
VERSION=${{ inputs.version }}
|
||||||
|
TOKEN=${{ inputs.token }}
|
||||||
|
|
||||||
|
if [ -n $TOKEN ]; then
|
||||||
|
TOKEN=(-H "Authorization: token $TOKEN")
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z $VERSION ]; then
|
if [ -z $VERSION ]; then
|
||||||
VERSION=$(curl https://api.github.com/repos/fluxcd/flux2/releases/latest -sL | grep tag_name | sed -E 's/.*"([^"]+)".*/\1/' | cut -c 2-)
|
VERSION=$(curl https://api.github.com/repos/fluxcd/flux2/releases/latest -sL "${TOKEN[@]}" | grep tag_name | sed -E 's/.*"([^"]+)".*/\1/' | cut -c 2-)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BIN_URL="https://github.com/fluxcd/flux2/releases/download/v${VERSION}/flux_${VERSION}_linux_${ARCH}.tar.gz"
|
BIN_URL="https://github.com/fluxcd/flux2/releases/download/v${VERSION}/flux_${VERSION}_linux_${ARCH}.tar.gz"
|
||||||
|
|||||||
Reference in New Issue
Block a user