This action installs and runs SQL Server for a GitHub Actions workflow. Also adds support for sqlcmd.
- Installs SQL Server
- On Windows, uses Chocolatey to install SQL Server Express.
- On Linux, runs SQL as a Docker container using the
mcr.microsoft.com/mssql/server:2022-latest
image. - Sets collation to case sensitive
SQL_Latin1_General_CP1_CS_AS
note SQL Azure is insensitiveCI_AS
- Creates environement variables for a connection string and for
sqlcmd
. - Waits for the SQL instance to be accessible.
- Creates a default database catalog.
Install SQL Server 2022 with a default database of nservicebus
and put the connection string in the environment variable SQL_SERVER_CONNECTION_STRING
:
steps:
- name: Install SQL Server
uses: Particular/install-sql-server-action@v1.3.0
with:
connection-string-env-var: SQL_SERVER_CONNECTION_STRING
catalog: nservicebus
It is also possible to specify the SQl server major version to be installed
steps:
- name: Install SQL Server
uses: Particular/install-sql-server-action@v1.3.0
with:
connection-string-env-var: SQL_SERVER_CONNECTION_STRING
sqlserver-version: 2019
catalog: nservicebus
To add additional parameters to the end of the connection string, such as Max Pool Size
. The connection string generated by the action already ends with a semicolon, and the extra-params
are appended at the end.
steps:
- name: Install SQL Server
uses: Particular/install-sql-server-action@v1.3.0
with:
connection-string-env-var: SQL_SERVER_CONNECTION_STRING
catalog: nservicebus
extra-params: "Max Pool Size=100;"
Parameter | Required | Default | Description |
---|---|---|---|
connection-string-env-var |
Yes | - | Environment variable name that will be filled with the SQL connection string, which can then be used in successive steps. |
catalog |
No | nservicebus |
The default catalog, which will be created by the action. |
collation |
No | SQL_Latin1_General_CP1_CS_AS |
The collation to use for the SQL Server database. Override to any available SQL collation. |
sqlserver-version |
No | 2022 |
The SQL server major version to use. |
extra-params |
No | - | Extra parameters to be appended to the end of the connection string. |
The action also makes it possible to run sqlcmd
. How it does this is different based on platform:
- Windows:
sqlcmd
is installed along with SQL Express. The action creates the necessary environment variables so thatsqlcmd
can be used without any additional login parameters. - Linux: A bash script named
sqlcmd
is created and added to the PATH. All commands to it are forwarded to the Docker container viadocker exec
. The Docker container is initialized with environment variables so that login parameters are not necessary.
For example:
steps:
- name: Install SQL Server
uses: Particular/install-sql-server-action@v1.0.0
with:
connection-string-env-var: SQL_SERVER_CONNECTION_STRING
catalog: nservicebus
- name: Create schemas
shell: pwsh
run: |
echo "Create additional schemas"
sqlcmd -Q "CREATE SCHEMA receiver AUTHORIZATION db_owner" -d "nservicebus"
sqlcmd -Q "CREATE SCHEMA sender AUTHORIZATION db_owner" -d "nservicebus"
sqlcmd -Q "CREATE SCHEMA db@ AUTHORIZATION db_owner" -d "nservicebus"