Add files via upload #27
This file contains hidden or 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: Update challenge on CTFd | |
| on: | |
| push: | |
| branches: [main, tgm-global-ci-cd-integration, staging] | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Extract branch name | |
| shell: bash | |
| run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT | |
| id: extract_branch | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-python@v4 | |
| - name: Install ctfcli | |
| run: pip3 install ctfcli | |
| - name: Install requirements | |
| run: pip3 install pyyaml | |
| - name: Set environment variables based on branch | |
| id: set-env | |
| run: | | |
| echo "${{ steps.extract_branch.outputs.branch }}" | |
| if [ ${{ steps.extract_branch.outputs.branch }} = "main" ]; then | |
| echo "CTFD_TOKEN=${{ secrets.CTFD_TOKEN }}" >> $GITHUB_ENV | |
| echo "CTFD_URL=${{ secrets.CTFD_URL }}" >> $GITHUB_ENV | |
| elif [ ${{ steps.extract_branch.outputs.branch }} = "staging" ]; then | |
| echo "CTFD_TOKEN=${{ secrets.CTFD_DEV_TOKEN }}" >> $GITHUB_ENV | |
| echo "CTFD_URL=${{ secrets.CTFD_DEV_URL }}" >> $GITHUB_ENV | |
| else | |
| exit 0 | |
| fi | |
| - name: Deploy | |
| env: | |
| CTFD_TOKEN: ${{ env.CTFD_TOKEN }} | |
| CTFD_URL: ${{ env.CTFD_URL }} | |
| run: cd $GITHUB_WORKSPACE && python3 ctfd.py | |
| - name: Sync challenges to CTFd | |
| env: | |
| CTFD_TOKEN: ${{ env.CTFD_TOKEN }} | |
| CTFD_URL: ${{ env.CTFD_URL }} | |
| run: | | |
| ctf challenge sync |