B4nner Challenge | SlyPex #13
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: Challenges Build Test | |
run-name: ${{ github.head_ref }} Challenge | ${{ github.event.pull_request.user.login }} | |
on: | |
pull_request: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
test: | |
name: 'Test Challenge Structure' | |
defaults: | |
run: | |
shell: bash | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Python Setup | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11.7' | |
- name: Test Challenge directory structure | |
run: .github/scripts/chall_structure_validator.py ${{github.head_ref}} | |
test_deployability: | |
name: 'Check Deployability' | |
defaults: | |
run: | |
shell: bash | |
outputs: | |
deploy_env: ${{ steps.deployable.outputs.deploy_env }} | |
runs-on: ubuntu-latest | |
needs: test | |
if: success() | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: 'Dockerfile Existance' | |
id: 'deployable' | |
run : .github/scripts/deployability_checker.sh ${{ github.head_ref }} | |
build_dockerfile: | |
name: 'Build Challenge Container using Dockerfile' | |
defaults: | |
run: | |
shell: bash | |
runs-on: ubuntu-latest | |
needs: test_deployability | |
if: ${{needs.test_deployability.outputs.deploy_env}} == 'Dockerfile' | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: 'Checkout' | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Build Challenge Image | |
run: docker buildx build ./${{github.head_ref}}/ --load -t "$(echo ${{github.head_ref}} | tr -t '[A-Z]' '[a-z]')":latest | |
- name: Launch Container | |
run: docker run -d "$(echo ${{github.head_ref}} | tr -t '[A-Z]' '[a-z]')":latest | |
- name: Check Running Container | |
run: docker ps -a | |
build_docker-compose: | |
name: 'Build Challenge Container using Docker Compose' | |
defaults: | |
run: | |
shell: bash | |
runs-on: ubuntu-latest | |
needs: test_deployability | |
if: ${{ needs.test_deployability.outputs.deploy_env }} == 'docker-compose' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Docker Compose Challenge Deployment | |
uses: hoverkraft-tech/[email protected] | |
with: | |
compose-file: ${{ github.head_ref }}/docker-compose.yml | |
up-flags: "--build" | |
- name: Test Challenge | |
run: docker ps -a |