Skip to content

matte/install-sql-server-action

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

install-sql-server

This action installs and runs SQL Server for a GitHub Actions workflow.

  1. 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.
  1. Creates environement variables for a connection string and for sqlcmd.
  2. Waits for the SQL instance to be accessible.
  3. Creates a default database catalog.

Usage

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.0.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.2.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.0.0
    with:
      connection-string-env-var: SQL_SERVER_CONNECTION_STRING
      catalog: nservicebus
      extra-params: "Max Pool Size=100;"

Parameters

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.
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

Using sqlcmd

The action creates the necessary environment variables so that sqlcmd can be used without any additional login parameters.

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"

About

Runs SQL Server for a GitHub Actions workflow

Resources

License

Stars

Watchers

Forks

Packages

No packages published