Skip to content

Particular/install-sql-server-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

install-sql-server

This action installs and runs SQL Server for a GitHub Actions workflow. Also adds support for sqlcmd.

  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.
  • Sets collation to case sensitive SQL_Latin1_General_CP1_CS_AS note SQL Azure is insensitive CI_AS
  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.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;"

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

Using sqlcmd

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 that sqlcmd 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 via docker 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"

About

Runs SQL Server for a GitHub Actions workflow

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 9