Skip to content

refactor(pwn/canary): 重构 Dockerfile,精简环境 #7

refactor(pwn/canary): 重构 Dockerfile,精简环境

refactor(pwn/canary): 重构 Dockerfile,精简环境 #7

Workflow file for this run

name: Challenge Canary
on:
push:
branches:
- "main"
- "pwn/canary"
paths:
- "!**/README.md"
- "challenges/pwn/canary/build/**"
workflow_dispatch:
env:
TYPE: pwn
NAME: canary
BRANCH: pwn/canary
EXECUTABLE: canary
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: |
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
docker cp temp:/home/ctf/${{ env.EXECUTABLE }} ./challenges/${{ env.TYPE }}/${{ env.NAME }}/attachments/${{ env.EXECUTABLE }}
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/${{ env.EXECUTABLE }}
git commit -m "chore(${{ env.BRANCH }}): update ${{ env.EXECUTABLE }} executable [skip ci]" || echo "No changes to commit"
git push