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-latestimage. - Sets collation to case sensitive
SQL_Latin1_General_CP1_CS_ASnote 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.4.0 # Check if this is the latest version at https://github.com/Particular/install-sql-server-action/tags
with:
connection-string-env-var: SQL_SERVER_CONNECTION_STRING
catalog: nservicebusIt 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.4.0 # Check if this is the latest version at https://github.com/Particular/install-sql-server-action/tags
with:
connection-string-env-var: SQL_SERVER_CONNECTION_STRING
sqlserver-version: 2019
catalog: nservicebusTo 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.4.0 # Check if this is the latest version at https://github.com/Particular/install-sql-server-action/tags
with:
connection-string-env-var: SQL_SERVER_CONNECTION_STRING
catalog: nservicebus
extra-params: "Max Pool Size=100;"To enable SQL Server Full-Text Search:
steps:
- name: Install SQL Server
uses: Particular/install-sql-server-action@v1.4.0 # Check if this is the latest version at https://github.com/Particular/install-sql-server-action/tags
with:
connection-string-env-var: SQL_SERVER_CONNECTION_STRING
catalog: nservicebus
enable-full-text-search: "true"| 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. |
enable-full-text-search |
No | "false" |
When set to "true", the action installs/enables and verifies SQL Server Full-Text Search before completion. |
When enable-full-text-search is enabled, setup time may increase because extra SQL components/packages are installed.
On Windows, this switches installation to Chocolatey's sql-server-express-adv package so Full-Text Search is available.
On Linux, the action adds the matching Microsoft SQL Server apt feed and installs mssql-server-fts for the requested SQL Server major version.
Current Full-Text Search setup support includes SQL Server major versions 2019, 2022, and 2025.
The action also makes it possible to run sqlcmd. How it does this is different based on platform:
- Windows:
sqlcmdis installed along with SQL Express. The action creates the necessary environment variables so thatsqlcmdcan be used without any additional login parameters. - Linux: A bash script named
sqlcmdis 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.4.0 # Check if this is the latest version at https://github.com/Particular/install-sql-server-action/tags
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"