|
1 | 1 | # sentry-release-deploy-action
|
2 |
| -A GitHub action that creates a deploy for a Sentry.io release. |
| 2 | + |
| 3 | +[](https://github.com/tclindner/sentry-release-deploy-action/blob/master/LICENSE) |
| 4 | +<a href="https://github.com/tclindner/sentry-release-deploy-action"><img alt="GitHub Actions status" src="https://github.com/tclindner/sentry-release-deploy-action/workflows/ci/badge.svg"></a> |
| 5 | +[](https://david-dm.org/tclindner/sentry-release-deploy-action) |
| 6 | +[](https://david-dm.org/tclindner/sentry-release-deploy-action#info=devDependencies) |
| 7 | + |
| 8 | +> A GitHub action that creates a [deploy for a Sentry.io release](https://docs.sentry.io/api/releases/post-release-deploys/). |
| 9 | +
|
| 10 | +## What is sentry-release-deploy-action? |
| 11 | + |
| 12 | +A GitHub action that makes is easy to create a deploy for an existing release in Sentry.io based on events in GitHub. Examples: |
| 13 | + |
| 14 | +* a GitHub release is published |
| 15 | +* a commit is pushed to master |
| 16 | +* a pull request is merged to master |
| 17 | + |
| 18 | +## How does it differ from sentry-releases-action? |
| 19 | + |
| 20 | +[sentry-releases-action](https://github.com/tclindner/sentry-releases-action) is used to create a new release, deploy it, associate commits, and finalize a release. sentry-releases-action should be used to create a release. This action is different because it only creates a deploy for an existing release. |
| 21 | + |
| 22 | +## How do I use it? |
| 23 | + |
| 24 | +First thing first, let's make sure you have the necessary pre-requisites. |
| 25 | + |
| 26 | +### Pre-requisites |
| 27 | +Create a workflow `.yml` file in your repo's `.github/workflows` directory. An [example workflow](#example-workflow---create-a-release) is available below. For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file). |
| 28 | + |
| 29 | +### Inputs |
| 30 | + |
| 31 | +#### `version` |
| 32 | + |
| 33 | +**Required** The version being deployed. You can optionally prefix it using `versionPrefix`. |
| 34 | + |
| 35 | +#### `environment` |
| 36 | + |
| 37 | +**Required** The name of the environment the release was deployed to. |
| 38 | + |
| 39 | +#### `versionPrefix` |
| 40 | + |
| 41 | +**Optional** String that is prefixed to the version to form the Sentry release name. |
| 42 | + |
| 43 | +> Please review Sentry's documentation regarding max length and supported characters in release names. |
| 44 | +
|
| 45 | +For more information on these inputs, see the [API Documentation](https://developer.github.com/v3/repos/releases/#input) |
| 46 | + |
| 47 | +### Environment Variables |
| 48 | + |
| 49 | +#### `SENTRY_AUTH_TOKEN` |
| 50 | + |
| 51 | +**Required** Sentry auth token. |
| 52 | + |
| 53 | +#### `SENTRY_ORG` |
| 54 | + |
| 55 | +**Required** Sentry organization. |
| 56 | + |
| 57 | +#### `SENTRY_PROJECT` |
| 58 | + |
| 59 | +**Required** Sentry project name. |
| 60 | + |
| 61 | +#### `SENTRY_URL` |
| 62 | + |
| 63 | +**Optional** URL to the Sentry instance, useful for e.g. on-prem deployments. |
| 64 | + |
| 65 | +## Example usage |
| 66 | + |
| 67 | +```yml |
| 68 | +name: Create a deploy for a Sentry.io release |
| 69 | + |
| 70 | +env: |
| 71 | + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} |
| 72 | + SENTRY_ORG: myAwesomeOrg |
| 73 | + SENTRY_PROJECT: myAwesomeProject |
| 74 | +with: |
| 75 | + version: ${{ github.ref }} |
| 76 | + environment: qa |
| 77 | +``` |
| 78 | +
|
| 79 | +> Note: `sentry-release-deploy-action` will automatically trim `refs/tags/` from `version` if a tag ref is passed. This means you can pass `GITHUB_REF` directly from release events without the need of mutating it first. |
| 80 | + |
| 81 | +### Full example workflow |
| 82 | + |
| 83 | +On every GitHub `release` event. |
| 84 | + |
| 85 | +```yaml |
| 86 | +name: ReleaseWorkflow |
| 87 | +
|
| 88 | +on: |
| 89 | + release: |
| 90 | + types: [published, prereleased] |
| 91 | +
|
| 92 | +
|
| 93 | +jobs: |
| 94 | + releaseApp: |
| 95 | + runs-on: ubuntu-latest |
| 96 | + steps: |
| 97 | + - name: Checkout code |
| 98 | + uses: actions/checkout@master |
| 99 | + - name: Deploy to dev |
| 100 | + uses: Your action for deployment |
| 101 | + - name: Create a Sentry.io release |
| 102 | + |
| 103 | + env: |
| 104 | + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} |
| 105 | + SENTRY_ORG: myAwesomeOrg |
| 106 | + SENTRY_PROJECT: myAwesomeProject |
| 107 | + with: |
| 108 | + tagName: ${{ github.ref }} |
| 109 | + environment: dev |
| 110 | + - name: Run integration tests against dev |
| 111 | + uses: Your action for testing |
| 112 | + - name: Deploy to qa |
| 113 | + uses: Your action for deployment |
| 114 | + - name: Create a deploy for a Sentry.io release |
| 115 | + |
| 116 | + env: |
| 117 | + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} |
| 118 | + SENTRY_ORG: myAwesomeOrg |
| 119 | + SENTRY_PROJECT: myAwesomeProject |
| 120 | + with: |
| 121 | + version: ${{ github.ref }} |
| 122 | + environment: qa |
| 123 | + - name: Run integration tests against qa |
| 124 | + uses: Your action for testing |
| 125 | +``` |
| 126 | + |
| 127 | +Assume you tagged your release as `v1.1.0`. `github.ref` would equal `refs/tags/v1.1.0`. This action automatically strips `refs/tags/`, so the Sentry release name is `v1.1.0`. |
| 128 | + |
| 129 | +### Example with optional release prefix |
| 130 | + |
| 131 | +```yaml |
| 132 | +name: Create a deploy for a Sentry.io release |
| 133 | + |
| 134 | +env: |
| 135 | + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} |
| 136 | + SENTRY_ORG: myAwesomeOrg |
| 137 | + SENTRY_PROJECT: myAwesomeProject |
| 138 | +with: |
| 139 | + version: ${{ github.ref }} |
| 140 | + environment: qa |
| 141 | + versionPrefix: myAwesomeProject- |
| 142 | +``` |
| 143 | + |
| 144 | +Scenario 1: Assume you tagged your release as `v1.1.0`. `github.ref` would equal `refs/tags/v1.1.0`. This action automatically strips `refs/tags/`, so the Sentry release name is `myAwesomeProject-v1.1.0`. |
| 145 | + |
| 146 | +Scenario 2: Assume you tagged your release as `1.1.0` and you set `releaseNamePrefix` to `myAwesomeProject@`. `github.ref` would equal `refs/tags/1.1.0`. This action automatically strips `refs/tags/`, so the Sentry release name is `[email protected]`. |
| 147 | + |
| 148 | +> Note: This action only works on Linux x86_64 systems. |
| 149 | + |
| 150 | +## Related |
| 151 | + |
| 152 | +[sentry-releases-action](https://github.com/tclindner/sentry-releases-action) - Action used to create releases. This action should be used first in your CI workflow. |
| 153 | + |
| 154 | +## Contributing |
| 155 | + |
| 156 | +Please see [CONTRIBUTING.md](CONTRIBUTING.md). |
| 157 | + |
| 158 | +## Release History |
| 159 | + |
| 160 | +Please see [CHANGELOG.md](CHANGELOG.md). |
| 161 | + |
| 162 | +## License |
| 163 | + |
| 164 | +Copyright (c) 2020 Thomas Lindner. Licensed under the MIT license. |
0 commit comments