From 0b97c2a8f88f09cf3918fe057357b4b66ed63239 Mon Sep 17 00:00:00 2001 From: Yeol <136407746+13m0n4de@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:59:53 +0800 Subject: [PATCH] =?UTF-8?q?ci(pwn/rop):=20=E6=B7=BB=E5=8A=A0=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pwn.rop.yml | 76 +++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/pwn.rop.yml diff --git a/.github/workflows/pwn.rop.yml b/.github/workflows/pwn.rop.yml new file mode 100644 index 0000000..d0ff57c --- /dev/null +++ b/.github/workflows/pwn.rop.yml @@ -0,0 +1,76 @@ +name: Challenge ROP + +on: + push: + branches: ["main", "pwn/rop"] + paths: + - "!**/README.md" + - "challenges/pwn/rop/build/**" + workflow_dispatch: + +env: + TYPE: pwn + NAME: rop + BRANCH: pwn/rop + EXECUTABLE: /home/ctf/rop + REGISTRY: ghcr.io + +jobs: + challenge-build: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.NAME }} + tags: | + type=raw,value=latest + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: challenges/${{ env.TYPE }}/${{ env.NAME }}/build + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + push: true + + - name: Extract executable from Docker image + run: | + docker create --name temp ${{ steps.meta.outputs.tags }} + mkdir -p ./challenges/${{ env.TYPE }}/${{ env.NAME }}/attachments + if [ ! -z "${{ env.EXECUTABLE }}" ]; then + docker cp temp:${{ env.EXECUTABLE }} ./challenges/${{ env.TYPE }}/${{ env.NAME }}/attachments/ + fi + if [ ! -z "${{ env.LIBC }}" ]; then + docker cp temp:${{ env.LIBC }} ./challenges/${{ env.TYPE }}/${{ env.NAME }}/attachments/ + fi + if [ ! -z "${{ env.LD }}" ]; then + docker cp temp:${{ env.LD }} ./challenges/${{ env.TYPE }}/${{ env.NAME }}/attachments/ + fi + docker rm temp + + - name: Commit and push changes + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add ./challenges/${{ env.TYPE }}/${{ env.NAME }}/attachments/ + git diff --staged --quiet || git commit -m "chore(${{ env.BRANCH }}): update attachments [skip ci]" + git push