Update generated files #207
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
name: Update generated files | |
on: | |
workflow_dispatch: {} | |
schedule: | |
- cron: "0 5 * * Thu" | |
permissions: | |
id-token: write | |
env: | |
DEFAULT_BRANCH: main | |
jobs: | |
update_generated_file: | |
strategy: | |
fail-fast: false | |
matrix: | |
resource: ["coredns", "aws-node"] | |
name: Update ${{ matrix.resource }} and open PR | |
runs-on: ubuntu-latest | |
container: public.ecr.aws/eksctl/eksctl-build:79ff6e4d9b5ba7e2bfb962efe2fcb7b2eebc1f2a | |
env: | |
GOPRIVATE: "" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 | |
with: | |
token: ${{ secrets.EKSCTLBOT_TOKEN }} | |
fetch-depth: 0 | |
- name: Configure AWS credentials for coredns update | |
if: ${{ matrix.resource == 'coredns' }} | |
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 | |
with: | |
aws-region: us-west-2 | |
role-duration-seconds: 900 | |
role-session-name: eksctl-update-coredns-assets | |
role-to-assume: ${{ secrets.UPDATE_COREDNS_ROLE_ARN }} | |
- name: Setup identity as eksctl-bot | |
uses: ./.github/actions/setup-identity | |
with: | |
token: "${{ secrets.EKSCTLBOT_TOKEN }}" | |
- name: Cache go-build and mod | |
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 #v4.0.0 | |
with: | |
path: | | |
~/.cache/go-build/ | |
~/go/pkg/mod/ | |
key: go-${{ hashFiles('go.sum') }} | |
restore-keys: | | |
go- | |
- name: Update ${{ matrix.resource }} | |
run: make update-${{ matrix.resource }} | |
- name: Commit changes | |
id: commit | |
run: | | |
git checkout $DEFAULT_BRANCH | |
git checkout -B update-${{ matrix.resource }} | |
git add -u | |
if ! EDITOR=true git commit -m "Update ${{ matrix.resource }}"; then | |
echo "changes=false" >> $GITHUB_OUTPUT | |
exit 0 | |
fi | |
echo "changes=true" >> $GITHUB_OUTPUT | |
! git diff --exit-code $DEFAULT_BRANCH HEAD | |
git push --force-with-lease origin HEAD | |
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1 | |
name: Open PR to ${{env.DEFAULT_BRANCH}} | |
if: steps.commit.outputs.changes == 'true' | |
with: | |
github-token: ${{ secrets.EKSCTLBOT_TOKEN }} | |
script: | | |
const { data: pr } = await github.rest.pulls.create({ | |
...context.repo, | |
title: "Update ${{ matrix.resource }}", | |
head: "update-${{ matrix.resource }}", | |
base: "${{ env.DEFAULT_BRANCH }}", | |
}); | |
await github.rest.issues.addLabels({ | |
...context.repo, | |
issue_number: pr.number, | |
labels: ["kind/improvement"], | |
}); |