Skip to content

Commit

Permalink
添加 pwn/shellcode workflows 文件
Browse files Browse the repository at this point in the history
  • Loading branch information
pn1fg committed Oct 14, 2023
1 parent 526bb21 commit b59b6dc
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/chal.pwn.shellcode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Challenge shellcode

on:
push:
branches: ["main"]
paths:
- "!**/README.md"
- "challenges/pwn/shellcode/build/**"
workflow_dispatch:

env:
TYPE: pwn
NAME: shellcode
REGISTRY: ghcr.io

jobs:
challenge-build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Compile
run: |
cd challenges/${{ env.TYPE }}/${{ env.NAME }}/build
gcc shellcode.c -o shellcode -no-pie -fno-stack-protector
mkdir -p ../attachments
cp -f shellcode ../attachments/
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.NAME }}
tags: |
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: Commit compiled file
run: |
git config --local user.email "145646018+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add challenges/${{ env.TYPE }}/${{ env.NAME }}/attachments/shellcode
git commit --allow-empty -m "Add compiled file"
- name: Pull changes
run: |
git pull --rebase
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- name: Re-pull on failure
if: ${{ failure() }}
run: git pull --rebase
- name: Re-push on failure
if: ${{ failure() }}
uses: ad-m/github-push-action@master
with:
force: true
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}

0 comments on commit b59b6dc

Please sign in to comment.