From 4696afa7925e3da927387930cf3e07fca3d19f3e Mon Sep 17 00:00:00 2001 From: Joseph Page Date: Wed, 21 Jun 2023 12:02:47 +0200 Subject: [PATCH] ci(setup-scalingo): add automation for releases (#2) --- .github/workflows/release-please.yml | 39 ++++++++++ .github/workflows/test-setup.yaml | 12 +-- README.md | 94 ++++++++++++++++++++--- setup-scalingo/action.yaml => action.yaml | 0 setup-scalingo/README.md | 86 --------------------- 5 files changed, 128 insertions(+), 103 deletions(-) create mode 100644 .github/workflows/release-please.yml rename setup-scalingo/action.yaml => action.yaml (100%) delete mode 100644 setup-scalingo/README.md diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..0a3a2d7 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,39 @@ +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +name: release-please-setup-scalingo + +env: + ACTION_NAME: release-please-action + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v3 + with: + release-type: simple + package-name: ${{ env.ACTION_NAME }} + command: github-release + - uses: actions/checkout@v2 + if: ${{ steps.release.outputs.release_created }} + - name: tag major and minor versions + if: ${{ steps.release.outputs.release_created }} + run: | + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/scalingo-community/setup-scalingo.git" + git tag -d v${{ steps.release.outputs.major }} || true + git tag -d v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true + git push origin :v${{ steps.release.outputs.major }} || true + git push origin :v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true + git tag -a v${{ steps.release.outputs.major }} -m "Release v${{ steps.release.outputs.major }}" + git tag -a v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} -m "Release v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}" + git push origin v${{ steps.release.outputs.major }} + git push origin v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} diff --git a/.github/workflows/test-setup.yaml b/.github/workflows/test-setup.yaml index f9aba13..480189f 100644 --- a/.github/workflows/test-setup.yaml +++ b/.github/workflows/test-setup.yaml @@ -13,14 +13,14 @@ jobs: test-latest-version: strategy: matrix: - os: [ubuntu-20.04, ubuntu-22.04, ubuntu-latest, macos-11, macos-12, macos-latest] + os: [ubuntu-20.04, ubuntu-22.04, ubuntu-latest, macos-11, macos-12] runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v3 - name: Setup scalingo CLI - uses: ./setup-scalingo + uses: ./ with: region: 'osc-fr1' - name: Check version @@ -39,14 +39,14 @@ jobs: test-specific-version: strategy: matrix: - os: [ubuntu-20.04, ubuntu-22.04, ubuntu-latest, macos-11, macos-12, macos-latest] + os: [ubuntu-20.04, ubuntu-22.04, ubuntu-latest, macos-11, macos-12] runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v3 - name: Setup scalingo CLI - uses: ./setup-scalingo + uses: ./ with: version: 1.28.1 region: 'osc-fr1' @@ -64,14 +64,14 @@ jobs: if: ${{ github.repository == 'scalingo-community/scalingo-actions' }} strategy: matrix: - os: [ubuntu-20.04, ubuntu-22.04, ubuntu-latest, macos-11, macos-12, macos-latest] + os: [ubuntu-20.04, ubuntu-22.04, ubuntu-latest, macos-11, macos-12] runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v3 - name: Setup scalingo CLI - uses: ./setup-scalingo + uses: ./ with: region: 'osc-fr1' api_token: ${{ secrets.SCALINGO_API_TOKEN }} diff --git a/README.md b/README.md index dded0b2..8cbf50a 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,86 @@ -## Github Actions for Scalingo +# scalingo-community/setup-scalingo -## Community-powered -These actions are a community initiative of users and are in no way related to or supported by Scalingo. -Your feedbacks and contributions are welcome to correct or improve them. +The `scalingo-community/setup-scalingo` action is a composite action that sets up Scalingo CLI in your GitHub Actions workflow by: -## Contributions are welcome +- Downloading the latest or a specific version of Scalingo CLI and adding it to the PATH. +- Configuring the Scalingo CLI configuration file with your region, app name and Scalingo API token. + +After you've used the action, subsequent steps in the same job can run arbitrary Scalingo commands using the GitHub Actions `run:` syntax. This allows most Scalingo commands to work exactly like they do on your local command line + +## Usage + +This action can be run on `ubuntu-latest` and `macos-latest` GitHub Actions runners. Note that the `region` input is always required. + +The default configuration installs the latest version of Scalingo CLI: +``` +steps: +- uses: scalingo-community/setup-scalingo@v1 + with: + region: 'osc-fr1' +``` + +Subsequent steps can launch command with the configured and authenticated CLI (you can create API Token [in the Scalingo dashboard](https://dashboard.scalingo.com/account/tokens)): +``` +steps: +- uses: scalingo-community/setup-scalingo@v1 + with: + region: 'osc-fr1' + api_token: '${{ secrets.scalingo_api_token }} + app_name: 'my_app' + +- run: scalingo restart # will restart all the processes of the app "my_app" in region "osc-fr1" +``` + + + +## Inputs +The action requires the following inputs: + +- `region` - The region of your app. + +The action also accepts the following optional inputs: + +- `api_token` - The Scalingo API token to use. If not provided, the subsequent steps will try to use the `SCALINGO_API_TOKEN` environment variable. +- `version` - The version of Scalingo CLI to install. If not provided, the action will install the latest version. +- `app_name` - The name of the app to use. If not provided, the subsequent steps will try to use the `SCALINGO_APP` environment variable. +- `git_remote` - Choose the name of Git remote to allow git operations (requires the `region` and `app_name` inputs). The default value is `scalingo`. + + +For testing or debugging purpose, the following inputs can also be used: + +- `scalingo_api_url` - The Scalingo API URL to use. If not provided, the action will use the default API URL for the given region. +- `scalingo_auth_url` - The Scalingo Auth URL to use. If not provided, the action will use the default Auth URL for the given region. +- `unsecure_ssl` - Disable SSL verification with APIs. +- `scalingo_db_url` - The Scalingo DB URL to use. If not provided, the action will use the default DB URL for the given region. +- `scalingo_ssh_host` - The Scalingo SSH Host to use. If not provided, the action will use the default SSH Host for the given region. + +## Features + +### Git remote auto-configuration + +If the code you provide the `region` and `app_name` inputs, the action will automatically configure a Git remote named `scalingo` to allow git operations on your app. This is useful if you want to run `git push scalingo master` in your workflow. + +``` +steps: +- name: Checkout code + uses: actions/checkout@v3 +- Configure Scalingo CLI + uses: scalingo-community/setup-scalingo@v1 + with: + region: 'osc-fr1' + app_name: 'my_app' +- name: Deploy to Scalingo with Git + run: git push scalingo main +``` + +### Custom version of Scalingo CLI + +You can install a specific version of Scalingo CLI: +``` +steps: +- uses: scalingo-community/setup-scalingo@v1 + with: + region: 'osc-fr1' + version: 1.28.2 +``` -_especially for the following topics_: -- rewriting the full setup-scalingo action in TS (instead of a composite "shell" Action, inspired from [hashicorp/setup-terraform](https://github.com/hashicorp/setup-terraform)), this will enable automatic caching thanks to `@actions/tool-cache` -- full-compatibility with Windows runners -- action to run commands in one-off containers -- action to create database backup -- action to create review app (with optional database copy !) diff --git a/setup-scalingo/action.yaml b/action.yaml similarity index 100% rename from setup-scalingo/action.yaml rename to action.yaml diff --git a/setup-scalingo/README.md b/setup-scalingo/README.md deleted file mode 100644 index 8cbf50a..0000000 --- a/setup-scalingo/README.md +++ /dev/null @@ -1,86 +0,0 @@ -# scalingo-community/setup-scalingo - -The `scalingo-community/setup-scalingo` action is a composite action that sets up Scalingo CLI in your GitHub Actions workflow by: - -- Downloading the latest or a specific version of Scalingo CLI and adding it to the PATH. -- Configuring the Scalingo CLI configuration file with your region, app name and Scalingo API token. - -After you've used the action, subsequent steps in the same job can run arbitrary Scalingo commands using the GitHub Actions `run:` syntax. This allows most Scalingo commands to work exactly like they do on your local command line - -## Usage - -This action can be run on `ubuntu-latest` and `macos-latest` GitHub Actions runners. Note that the `region` input is always required. - -The default configuration installs the latest version of Scalingo CLI: -``` -steps: -- uses: scalingo-community/setup-scalingo@v1 - with: - region: 'osc-fr1' -``` - -Subsequent steps can launch command with the configured and authenticated CLI (you can create API Token [in the Scalingo dashboard](https://dashboard.scalingo.com/account/tokens)): -``` -steps: -- uses: scalingo-community/setup-scalingo@v1 - with: - region: 'osc-fr1' - api_token: '${{ secrets.scalingo_api_token }} - app_name: 'my_app' - -- run: scalingo restart # will restart all the processes of the app "my_app" in region "osc-fr1" -``` - - - -## Inputs -The action requires the following inputs: - -- `region` - The region of your app. - -The action also accepts the following optional inputs: - -- `api_token` - The Scalingo API token to use. If not provided, the subsequent steps will try to use the `SCALINGO_API_TOKEN` environment variable. -- `version` - The version of Scalingo CLI to install. If not provided, the action will install the latest version. -- `app_name` - The name of the app to use. If not provided, the subsequent steps will try to use the `SCALINGO_APP` environment variable. -- `git_remote` - Choose the name of Git remote to allow git operations (requires the `region` and `app_name` inputs). The default value is `scalingo`. - - -For testing or debugging purpose, the following inputs can also be used: - -- `scalingo_api_url` - The Scalingo API URL to use. If not provided, the action will use the default API URL for the given region. -- `scalingo_auth_url` - The Scalingo Auth URL to use. If not provided, the action will use the default Auth URL for the given region. -- `unsecure_ssl` - Disable SSL verification with APIs. -- `scalingo_db_url` - The Scalingo DB URL to use. If not provided, the action will use the default DB URL for the given region. -- `scalingo_ssh_host` - The Scalingo SSH Host to use. If not provided, the action will use the default SSH Host for the given region. - -## Features - -### Git remote auto-configuration - -If the code you provide the `region` and `app_name` inputs, the action will automatically configure a Git remote named `scalingo` to allow git operations on your app. This is useful if you want to run `git push scalingo master` in your workflow. - -``` -steps: -- name: Checkout code - uses: actions/checkout@v3 -- Configure Scalingo CLI - uses: scalingo-community/setup-scalingo@v1 - with: - region: 'osc-fr1' - app_name: 'my_app' -- name: Deploy to Scalingo with Git - run: git push scalingo main -``` - -### Custom version of Scalingo CLI - -You can install a specific version of Scalingo CLI: -``` -steps: -- uses: scalingo-community/setup-scalingo@v1 - with: - region: 'osc-fr1' - version: 1.28.2 -``` -