From 544efdd4d7ac709f78586459425ef11a3794a074 Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Mon, 20 Sep 2021 22:55:16 +0100 Subject: [PATCH] ci: Add action for xtask codegen This commit adds a github action that will - check out aya and libbpf - run xtask codegen - if there is a diff, open commit changes to the codegen branch - if changes were comitted, open a pull-request Signed-off-by: Dave Tucker --- .github/workflows/gen.yml | 51 +++++++++++++++++++++++++++++++++++++++ .gitignore | 1 + 2 files changed, 52 insertions(+) create mode 100644 .github/workflows/gen.yml diff --git a/.github/workflows/gen.yml b/.github/workflows/gen.yml new file mode 100644 index 00000000..aac98417 --- /dev/null +++ b/.github/workflows/gen.yml @@ -0,0 +1,51 @@ +name: codegen + +on: workflow_dispatch + +jobs: + codegen: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + + - uses: actions/checkout@v2 + with: + repository: libbpf/libbpf + path: libbpf + + - name: libbpf-version + working-directory: libbpf + run: echo "LIBBPF_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV + + - uses: Swatinem/rust-cache@v1 + + - name: Run codegen + run: | + cargo xtask codegen --libbpf-dir ./libbpf + + - name: Check for changes + run: | + git diff --quiet || echo "COMMIT_CHANGES=1" >> $GITHUB_ENV + + - name: Commit Changes + id: commit + if: env.COMMIT_CHANGES == 1 + uses: devops-infra/action-commit-push@master + with: + github_token: "${{ secrets.GITHUB_TOKEN }}" + commit_prefix: "[codegen] Update libbpf to ${{ env.LIBBPF_SHA }}" + commit_message: "Created using GitHub Actions" + target_branch: codegen + + + - name: Create pull request + if: steps.commit.outputs.files_changed != '' + uses: devops-infra/action-pull-request@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + body: "**Automated pull request**

Update libbpf to ${{ env.LIBBPF_SHA }}" + title: Update libbpf to ${{ env.LIBBPF_SHA }} + source_branch: codegen + target_branch: main + get_diff: true \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9b3d7e22..6482bd3c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ Cargo.lock target/ .vscode +libbpf/ \ No newline at end of file