|
| 1 | +name: "Copilot Setup Steps" |
| 2 | + |
| 3 | +# Based on https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-environment |
| 4 | + |
| 5 | +# Automatically run the setup steps when they are changed to allow for easy validation, and |
| 6 | +# allow manual testing through the repository's "Actions" tab |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + push: |
| 10 | + paths: |
| 11 | + - .github/workflows/copilot-setup-steps.yml |
| 12 | + pull_request: |
| 13 | + paths: |
| 14 | + - .github/workflows/copilot-setup-steps.yml |
| 15 | + |
| 16 | +jobs: |
| 17 | + # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. |
| 18 | + copilot-setup-steps: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + # env: |
| 22 | + # MSSQL_IMAGE: mcr.microsoft.com/mssql/server:2025-latest |
| 23 | + |
| 24 | + # Install SQL Server via a docker container. |
| 25 | + # It's better to do this rather than e.g. use a testcontainer, because then the agent can reuse the same container |
| 26 | + # and instance of SQL Server rather than have to start it up each time it needs to iterate and run a test. |
| 27 | + services: |
| 28 | + mssql: |
| 29 | + image: mcr.microsoft.com/mssql/server:2025-latest |
| 30 | + env: |
| 31 | + ACCEPT_EULA: "Y" |
| 32 | + SA_PASSWORD: ${{ secrets.MSSQL_SA_PASSWORD }} |
| 33 | + ports: |
| 34 | + - 1433:1433 |
| 35 | + options: >- |
| 36 | + --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${{ secrets.MSSQL_SA_PASSWORD }} -Q 'SELECT 1'" |
| 37 | + --health-interval=2s |
| 38 | + --health-retries=30 |
| 39 | + --health-timeout=5s |
| 40 | +
|
| 41 | +# permissions: |
| 42 | +# contents: read |
| 43 | + |
| 44 | + # You can define any steps you want, and they will run before the agent starts. |
| 45 | + # If you do not check out your code, Copilot will do this for you. |
| 46 | + steps: |
| 47 | + - name: Checkout |
| 48 | + uses: actions/checkout@v5 |
| 49 | + |
| 50 | + - name: Restore |
| 51 | + run: ./restore.sh |
| 52 | + |
| 53 | + # - name: Setup .NET Core SDK |
| 54 | + # uses: actions/setup-dotnet@v5 |
| 55 | + |
| 56 | + # Install SQL Server via a docker container. |
| 57 | + # It's better to do this rather than e.g. use a testcontainer, because then the agent can reuse the same container |
| 58 | + # and instance of SQL Server rather than have to start it up each time it needs to iterate and run a test. |
| 59 | + # - name: Start SQL Server container |
| 60 | + # run: | |
| 61 | + # docker pull "$MSSQL_IMAGE" |
| 62 | + # docker run --name mssql -e ACCEPT_EULA=Y -e "SA_PASSWORD=${SA_PASSWORD}" -p 1433:1433 -d "$MSSQL_IMAGE" |
| 63 | + |
| 64 | + # - name: Wait for SQL Server to be ready |
| 65 | + # shell: bash |
| 66 | + # run: | |
| 67 | + # # Simple wait loop; the container typically needs ~10-20s |
| 68 | + # for i in {1..60}; do |
| 69 | + # if docker exec mssql /opt/mssql-tools/bin/sqlcmd \ |
| 70 | + # -S localhost -U sa -P "${{ secrets.MSSQL_SA_PASSWORD }}" \ |
| 71 | + # -Q "SELECT 1" &>/dev/null; then |
| 72 | + # echo "SQL Server is up" |
| 73 | + # break |
| 74 | + # fi |
| 75 | + # echo "Waiting for SQL Server..." && sleep 1 |
| 76 | + # done |
| 77 | + |
| 78 | + - name: Export SQL Server connection string for the agent's session |
| 79 | + run: echo "Test__SqlServer__DefaultConnection=Server=localhost;Database=admin;User=SA;Password=${{ secrets.MSSQL_SA_PASSWORD }};Connect Timeout=60;ConnectRetryCount=0;Trust Server Certificate=true" >> "$GITHUB_ENV" |
0 commit comments