Skip to content

Commit

Permalink
ci(pwn/nc): 添加工作流文件
Browse files Browse the repository at this point in the history
  • Loading branch information
13m0n4de committed Oct 18, 2024
1 parent 7a00e22 commit b284413
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/pwn.nc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Challenge Netcat

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

env:
TYPE: pwn
NAME: nc
BRANCH: pwn/nc
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

0 comments on commit b284413

Please sign in to comment.