feat(pwn/srand): 添加镜像构建文件 #1
Workflow file for this run
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: Challenge 猜数字 | |
on: | |
push: | |
branches: ["main", "pwn/srand"] | |
paths: | |
- "!**/README.md" | |
- "challenges/pwn/srand/build/**" | |
workflow_dispatch: | |
env: | |
TYPE: pwn | |
NAME: srand | |
BRANCH: pwn/srand | |
EXECUTABLE: /home/ctf/game | |
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@v6 | |
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 "[email protected]" | |
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 |