Skip to content

Commit

Permalink
ci(setup-scalingo): add automation for releases (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephpage authored Jun 21, 2023
1 parent 0677976 commit 4696afa
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 103 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -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 }}
12 changes: 6 additions & 6 deletions .github/workflows/test-setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand All @@ -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 }}
Expand Down
94 changes: 83 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 !)
File renamed without changes.
86 changes: 0 additions & 86 deletions setup-scalingo/README.md

This file was deleted.

0 comments on commit 4696afa

Please sign in to comment.