Skip to content

Commit

Permalink
INFRA-2087 auto generated issues for mobile and extension repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
rrabenda committed Oct 4, 2024
1 parent f8080cd commit dc8c828
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/create-update-issues.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Create Update Issues

on:
workflow_call:
inputs:
AUTH_APP_ID:
description: Github app id to authenticate in mobile and extention repositories
type: string
required: true
secrets:
AUTH_APP_PRIVATE_KEY:
description: Github app private key to authenticate in mobile and extention repositories
required: true

jobs:
create-update-issues:
permissions:
issues: write
runs-on: ubuntu-latest
steps:
- name: Checkout head
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get release tag
id: releaseTag
run: echo "tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT

- name: Check released package
id: releaseCheck
env:
tag: ${{ steps.releaseTag.outputs.tag }}
run: |
if [[ ${tag} == @metamask/* ]] ; then
# Extract package name without the leading '@'
package_name="${tag#@}"
package_name="${package_name%@*}"
echo "package_name=${package_name}" >> $GITHUB_OUTPUT
# Extract version number
version="${tag##*@}"
echo "version=${version}" >> $GITHUB_OUTPUT
# Check if version number ends with .0.0
if [[ $version == *.0.0 ]]; then
echo "$package_name major update"
echo "major_version=true" >> $GITHUB_OUTPUT
else
echo "$package_name minor update"
echo "major_version=false" >> $GITHUB_OUTPUT
fi
else
echo 'Monorepo version update'
echo "major_version=false" >> $GITHUB_OUTPUT
fi
- name: Generate a token
id: generate-token
if: ${{ steps.releaseCheck.outputs.major_version == 'true' }}
uses: actions/create-github-app-token@v1
with:
app-id: ${{ inputs.AUTH_APP_ID }}
private-key: ${{ secrets.AUTH_APP_PRIVATE_KEY }}
repositories: metamask-mobile, metamask-extension

- name: Create Issue
if: ${{ steps.releaseCheck.outputs.major_version == 'true' }}
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
package: ${{ steps.releaseCheck.outputs.package_name }}
version: ${{ steps.releaseCheck.outputs.version }}
run: |
echo "Creating new issue..."
gh issue create --title "Update ${package} to version ${version}" --body "Please update ${package} to version ${version}" --repo "MetaMask/metamask-extension"
gh issue create --title "Update ${package} to version ${version}" --body "Please update ${package} to version ${version}" --repo "MetaMask/metamask-mobile"
12 changes: 12 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

create-update-issues:
name: Create update issues
needs: [is-release, publish-release]
if: needs.is-release.outputs.IS_RELEASE == 'true'
permissions:
issues: write
uses: ./.github/workflows/create-update-issues.yaml
with:
AUTH_APP_ID: ${{ vars.AUTH_APP_ID }}
secrets:
AUTH_APP_PRIVATE_KEY: ${{ secrets.AUTH_APP_PRIVATE_KEY }}

all-jobs-complete:
name: All jobs complete
runs-on: ubuntu-latest
Expand Down

0 comments on commit dc8c828

Please sign in to comment.