This repository was archived by the owner on May 17, 2026. It is now read-only.
Add practice exam environment with comprehensive lab provisioning #4
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: CI/CD - Lint and Deploy | |
| on: | |
| push: | |
| branches: [main, develop, provision-lab] | |
| pull_request: | |
| branches: [main, develop] | |
| workflow_dispatch: | |
| # Sets permissions for GitHub Pages deployment | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Allow only one concurrent deployment | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| lint-and-build: | |
| runs-on: ubuntu-latest | |
| name: Lint Code and Build Documentation | |
| outputs: | |
| should-deploy: ${{ steps.check-deploy.outputs.should-deploy }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install Python dependencies | |
| run: | | |
| pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Cache pre-commit hooks | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pre-commit | |
| key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} | |
| - name: Install Ansible collections for linting | |
| run: | | |
| # Install collections from requirements.yml globally so pre-commit can find them | |
| ansible-galaxy collection install -r vagrant/requirements.yml | |
| - name: Run pre-commit hooks | |
| run: pre-commit run --all-files --show-diff-on-failure | |
| - name: Build MkDocs documentation | |
| run: mkdocs build --verbose --clean | |
| - name: Check if deployment needed | |
| id: check-deploy | |
| run: | | |
| if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| echo "should-deploy=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "should-deploy=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup Pages | |
| if: steps.check-deploy.outputs.should-deploy == 'true' | |
| uses: actions/configure-pages@v4 | |
| - name: Upload artifact | |
| if: steps.check-deploy.outputs.should-deploy == 'true' | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./site | |
| deploy: | |
| if: needs.lint-and-build.outputs.should-deploy == 'true' | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: lint-and-build | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |