pre-release #14
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
--- | |
# When triggered it will prepare the release by creating a Pull Request with the | |
# changes to be merged. Then it will be possible to run the release manually | |
name: pre-release | |
on: | |
workflow_dispatch: | |
inputs: | |
dry-run: | |
type: boolean | |
description: 'Run release process in dry-run mode' | |
default: true | |
permissions: | |
contents: read | |
env: | |
SLACK_BUILD_MESSAGE: "Build: (<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|here>)" | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get token | |
id: get_token | |
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0 | |
with: | |
app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }} | |
private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }} | |
permissions: >- | |
{ | |
"contents": "write", | |
"pull_requests": "write" | |
} | |
repositories: >- | |
["apm-agent-rum-js"] | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ steps.get_token.outputs.token }} | |
- uses: elastic/oblt-actions/git/setup@v1 | |
with: | |
github-token: ${{ steps.get_token.outputs.token }} | |
# Temporary fix for "ValueError: invalid mode: 'rU' while trying to load binding.gyp" | |
# See https://github.com/nodejs/node-gyp/issues/2219 | |
# This can be removed when "node-gyp" is updated | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
- name: Install dependencies | |
run: npm ci | |
# This prevent lerna command from throwing this error: | |
# "Working tree has uncommitted changes, please commit or remove the following changes before continuing" | |
- name: Ignore git uncommitted changes | |
run: git update-index --skip-worktree .npmrc | |
- name: Create PR with the required changes to be released | |
id: pre-release | |
env: | |
DRY_RUN: "${{ inputs.dry-run }}" | |
# as long as we use the GitHub app for generating the token, we need to pass the token to the action | |
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }} | |
run: | | |
npm run ci:pre-release | |
if [ -e .pr.txt ] ; then | |
echo "pr=$(cat .pr.txt)" >> "$GITHUB_OUTPUT" | |
rm .pr.txt | |
fi | |
- if: ${{ success() && inputs.dry-run == false }} | |
uses: elastic/oblt-actions/slack/send@v1 | |
with: | |
bot-token: ${{ secrets.SLACK_BOT_TOKEN }} | |
channel-id: "#apm-agent-js" | |
message: | | |
:runner: [${{ github.repository }}] Pre Release has been triggered. Review the PR ${{ steps.pre-release.outputs.pr }}. ${{ env.SLACK_BUILD_MESSAGE }} | |
- if: ${{ failure() && inputs.dry-run == false }} | |
uses: elastic/oblt-actions/slack/send@v1 | |
with: | |
bot-token: ${{ secrets.SLACK_BOT_TOKEN }} | |
channel-id: "#apm-agent-js" | |
message: | | |
:ghost: [${{ github.repository }}] Pre Release failed. ${{ env.SLACK_BUILD_MESSAGE }} |