-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ihostage/sharable-actions
GitHub Reusing Workflows
- Loading branch information
Showing
5 changed files
with
310 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Validate Binary Compatibility | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
java: | ||
type: string | ||
required: false | ||
default: 8 | ||
|
||
jobs: | ||
cmd: | ||
name: JDK ${{ inputs.java }} | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
# we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves | ||
fetch-depth: 0 | ||
|
||
- name: Coursier Cache | ||
uses: coursier/[email protected] | ||
|
||
- name: Install AdoptOpenJDK | ||
uses: coursier/[email protected] | ||
with: | ||
jvm: adopt:${{ inputs.java }} | ||
|
||
- name: Binary Compatibility | ||
run: sbt +mimaReportBinaryIssues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Publish | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
java: | ||
type: string | ||
required: false | ||
default: 8 | ||
secrets: | ||
username: | ||
required: true | ||
password: | ||
required: true | ||
pgp_passphrase: | ||
required: true | ||
pgp_secret: | ||
required: true | ||
|
||
jobs: | ||
cmd: | ||
name: JDK ${{ inputs.java }} | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
# we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves | ||
fetch-depth: 0 | ||
|
||
- name: Coursier Cache | ||
uses: coursier/[email protected] | ||
|
||
- name: Install AdoptOpenJDK | ||
uses: coursier/[email protected] | ||
with: | ||
jvm: adopt:${{ inputs.java }} | ||
|
||
- name: Publish artifcats | ||
run: sbt ci-release | ||
env: | ||
SONATYPE_USERNAME: ${{ secrets.username }} | ||
SONATYPE_PASSWORD: ${{ secrets.password }} | ||
PGP_PASSPHRASE: ${{ secrets.pgp_passphrase }} | ||
PGP_SECRET: ${{ secrets.pgp_secret }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: SBT command on matrix Java/Scala versions | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
java: | ||
type: string | ||
required: true | ||
scala: | ||
type: string | ||
required: true | ||
cmd: | ||
type: string | ||
required: true | ||
|
||
jobs: | ||
cmd: | ||
name: Scala ${{ matrix.scala }} & JDK ${{ matrix.java }} | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
# WA: https://github.community/t/reusable-workflow-with-strategy-matrix/205676/6 | ||
matrix: | ||
java: ${{ fromJson(inputs.java) }} | ||
scala: ${{ fromJson(inputs.scala) }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
# we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves | ||
fetch-depth: 0 | ||
|
||
- name: Coursier Cache | ||
uses: coursier/[email protected] | ||
|
||
- name: Install AdoptOpenJDK | ||
uses: coursier/[email protected] | ||
with: | ||
jvm: adopt:${{ matrix.java }} | ||
|
||
- name: Run sbt command | ||
run: ${{ inputs.cmd }} | ||
env: | ||
SCALA_VERSION: ${{ matrix.scala }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: SBT command on single Java verion | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
java: | ||
type: string | ||
required: false | ||
default: 8 | ||
cmd: | ||
required: true | ||
type: string | ||
cache-key: | ||
type: string | ||
required: false | ||
default: "" | ||
cache-path: | ||
type: string | ||
required: false | ||
default: "" | ||
|
||
jobs: | ||
cmd: | ||
name: JDK ${{ inputs.java }} | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
# we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves | ||
fetch-depth: 0 | ||
|
||
- name: Coursier Cache | ||
uses: coursier/[email protected] | ||
|
||
- name: Custom Cache | ||
uses: actions/cache@v2 | ||
if: ${{ inputs.cache-key != '' && inputs.cache-path != '' }} | ||
with: | ||
key: ${{ inputs.cache-key }} | ||
path: ${{ inputs.cache-path }} | ||
|
||
- name: Install AdoptOpenJDK | ||
uses: coursier/[email protected] | ||
with: | ||
jvm: adopt:${{ inputs.java }} | ||
|
||
- name: Run sbt command | ||
run: ${{ inputs.cmd }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,142 @@ | ||
# .github | ||
# Playframework GitHub integration | ||
|
||
This repository contains a few configurations of GitHub features. For example a [Reusing workflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows) or | ||
[Starter workflows](https://docs.github.com/en/actions/using-workflows/creating-starter-workflows-for-your-organization) as [GitHub Actions](https://docs.github.com/en/actions) features. | ||
|
||
## GitHub Actions Reusing Workflows | ||
|
||
* [Single SBT task](#single-sbt-task) | ||
* [Java/Scala matrix SBT task](#javascala-matrix-sbt-task) | ||
* [Publishing to Sonatype](#publishing-to-sonatype) | ||
* [Validate Binary Compatibility](#validate-binary-compatibility) | ||
|
||
### Single SBT task | ||
|
||
This workflow is used for running a single SBT task. It can to use for running an any BASH script or command, but we don't recommend doing that. | ||
|
||
**Path**: [`.github/workflows/sbt.yml`](.github/workflows/sbt.yml) | ||
|
||
**Image**: [Ubuntu 20.04](https://hub.docker.com/layers/ubuntu/library/ubuntu/20.04/images/sha256-57df66b9fc9ce2947e434b4aa02dbe16f6685e20db0c170917d4a1962a5fe6a9?context=explore) | ||
|
||
**Uses actions**: | ||
* [Coursier/Setup Action](https://github.com/coursier/setup-action) | ||
* [Coursier/Cache Action](https://github.com/coursier/cache-action) | ||
|
||
**Parameters**: | ||
|
||
| Parameter | Since | Required | Default | Description | | ||
|------------|-------|--------------------|---------|----------------------| | ||
| cmd | 1.0.0 | :exclamation: | - | Running command | | ||
| java | 1.0.0 | :heavy_minus_sign: | 8 | _AdoptJDK_ version | | ||
| cache-key | 1.0.0 | :heavy_minus_sign: | '' | Key of custom cache | | ||
| cache-path | 1.0.0 | :heavy_minus_sign: | '' | Path of custom cache | | ||
|
||
**How to use**: | ||
|
||
```yaml | ||
uses: playframework/.github/.github/workflows/sbt.yml@v1 | ||
with: | ||
cmd: sbt test | ||
``` | ||
### Java/Scala matrix SBT task | ||
This workflow is used for running an SBT task on matrix of Java/Scala versions. | ||
**Path**: [`.github/workflows/sbt-matrix.yml`](.github/workflows/sbt-matrix.yml) | ||
|
||
**Image**: [Ubuntu 20.04](https://hub.docker.com/layers/ubuntu/library/ubuntu/20.04/images/sha256-57df66b9fc9ce2947e434b4aa02dbe16f6685e20db0c170917d4a1962a5fe6a9?context=explore) | ||
|
||
**Uses actions**: | ||
* [Coursier/Setup Action](https://github.com/coursier/setup-action) | ||
* [Coursier/Cache Action](https://github.com/coursier/cache-action) | ||
|
||
**Parameters**: | ||
|
||
| Parameter | Since | Required | Default | Description | | ||
|-----------|-------|-----------------|---------|--------------------| | ||
| cmd | 1.0.0 | :exclamation: | - | Running command | | ||
| java | 1.0.0 | :exclamation: | - | _AdoptJDK_ version | | ||
| scala | 1.0.0 | :exclamation: | - | _Scala_ version | | ||
|
||
**How to use**: | ||
|
||
```yaml | ||
uses: playframework/.github/.github/workflows/sbt-matrix.yml@v1 | ||
with: | ||
java: >- | ||
[ "11", "8" ] | ||
scala: >- | ||
[ "2.12.15", "2.13.8", "3.0.2" ] | ||
cmd: sbt test | ||
``` | ||
|
||
### Publishing to Sonatype | ||
|
||
This workflow is used for publishing snapshots artifacts to [Sonatype Snapshots](https://oss.sonatype.org/content/repositories/snapshots/com/typesafe/play/) repository or release artifacts to [Maven Central](https://repo1.maven.org/maven2/com/typesafe/play/). | ||
|
||
:warning: For using this workflow project must uses the [CI Release](https://github.com/sbt/sbt-ci-release) plugin. | ||
|
||
**Path**: [`.github/workflows/publish.yml`](.github/workflows/publish.yml) | ||
|
||
**Image**: [Ubuntu 20.04](https://hub.docker.com/layers/ubuntu/library/ubuntu/20.04/images/sha256-57df66b9fc9ce2947e434b4aa02dbe16f6685e20db0c170917d4a1962a5fe6a9?context=explore) | ||
|
||
**Uses actions**: | ||
* [Coursier/Setup Action](https://github.com/coursier/setup-action) | ||
* [Coursier/Cache Action](https://github.com/coursier/cache-action) | ||
|
||
**Parameters**: | ||
|
||
| Parameter | Since | Required | Default | Description | | ||
|-----------|-------|--------------------|---------|--------------------| | ||
| java | 1.0.0 | :heavy_minus_sign: | 8 | _AdoptJDK_ version | | ||
|
||
**Secrets**: | ||
|
||
| Secret | Since | Required | Default | Description | | ||
|----------------|-------|-----------------|---------|---------------------------| | ||
| username | 1.0.0 | :exclamation: | - | Sonatype account username | | ||
| password | 1.0.0 | :exclamation: | - | Sonatype account password | | ||
| pgp_passphrase | 1.0.0 | :exclamation: | - | Password for GPG key | | ||
| pgp_secret | 1.0.0 | :exclamation: | - | Base64 of GPG private key | | ||
|
||
**How to use**: | ||
|
||
```yaml | ||
uses: playframework/.github/.github/workflows/publish.yml@v1 | ||
secrets: | ||
username: ${{ secrets.SONATYPE_USERNAME }} | ||
password: ${{ secrets.SONATYPE_PASSWORD }} | ||
pgp_passphrase: ${{ secrets.PGP_PASSPHRASE }} | ||
pgp_secret: ${{ secrets.PGP_SECRET }} | ||
``` | ||
|
||
### Validate Binary Compatibility | ||
|
||
This workflow is used for validate binary compatibility the current version. | ||
|
||
:warning: For using this workflow project must uses the [SBT MiMa](https://github.com/lightbend/mima) plugin. | ||
|
||
**Path**: [`.github/workflows/binary-check.yml`](.github/workflows/binary-check.yml) | ||
|
||
**Image**: [Ubuntu 20.04](https://hub.docker.com/layers/ubuntu/library/ubuntu/20.04/images/sha256-57df66b9fc9ce2947e434b4aa02dbe16f6685e20db0c170917d4a1962a5fe6a9?context=explore) | ||
|
||
**Uses actions**: | ||
* [Coursier/Setup Action](https://github.com/coursier/setup-action) | ||
* [Coursier/Cache Action](https://github.com/coursier/cache-action) | ||
|
||
**Parameters**: | ||
|
||
| Parameter | Since | Required | Default | Description | | ||
|-----------|-------|--------------------|---------|--------------------| | ||
| java | 1.0.0 | :heavy_minus_sign: | 8 | _AdoptJDK_ version | | ||
|
||
**How to use**: | ||
|
||
```yaml | ||
uses: playframework/.github/.github/workflows/binary-check.yml@v1 | ||
``` | ||
|
||
## GitHub Actions Starter workflows | ||
|
||
TODO |