diff --git a/.github/workflows/closed_issue_message.yml b/.github/workflows/closed_issue_message.yml deleted file mode 100644 index 777d2271a5..0000000000 --- a/.github/workflows/closed_issue_message.yml +++ /dev/null @@ -1,17 +0,0 @@ -# Add warning message to issues when they are closed. - -name: Closed Issue Message -on: - issues: - types: [closed] -jobs: - auto_comment: - runs-on: ubuntu-latest - steps: - - uses: aws-actions/closed-issue-message@36b7048ea77bb834d16e7a7c5b5471ac767a4ca1 # v1 - with: - # These inputs are both required - repo-token: "${{ secrets.GITHUB_TOKEN }}" - message: | - This issue is now closed. Comments on closed issues are hard for our team to see. - If you need more assistance, please open a new issue that references this one. diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml deleted file mode 100644 index 21299fbb8e..0000000000 --- a/.github/workflows/gradle.yml +++ /dev/null @@ -1,26 +0,0 @@ -# This workflow will build a Java project with Gradle -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - -name: Java CI with Gradle - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2 - - name: Set up JDK 11 - uses: actions/setup-java@b6e674f4b717d7b0ae3baee0fbe79f498905dfde # v1 - with: - java-version: 11 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle - run: scripts/retry.sh 3 "./gradlew clean build" diff --git a/.github/workflows/issue_closed.yml b/.github/workflows/issue_closed.yml new file mode 100644 index 0000000000..14f4a8afd1 --- /dev/null +++ b/.github/workflows/issue_closed.yml @@ -0,0 +1,32 @@ +name: Issue Closed + +on: + issues: + types: [closed] + +permissions: + issues: write + +jobs: + cleanup-labels: + runs-on: ubuntu-latest + if: ${{ (contains(github.event.issue.labels.*.name, 'pending-response') || contains(github.event.issue.labels.*.name, 'closing soon') || contains(github.event.issue.labels.*.name, 'pending-release')|| contains(github.event.issue.labels.*.name, 'pending-triage')) }} + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 + - name: remove unnecessary labels after closing + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_NUMBER: ${{ github.event.issue.number }} + run: | + gh issue edit $ISSUE_NUMBER --remove-label "closing soon" --remove-label "pending-response" --remove-label "pending-release" --remove-label "pending-triage" + + comment-visibility-warning: + runs-on: ubuntu-latest + steps: + - uses: aws-actions/closed-issue-message@36b7048ea77bb834d16e7a7c5b5471ac767a4ca1 # v1 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" + message: | + This issue is now closed. Comments on closed issues are hard for our team to see. + If you need more assistance, please open a new issue that references this one. \ No newline at end of file diff --git a/.github/workflows/issue_comment.yml b/.github/workflows/issue_comment.yml new file mode 100644 index 0000000000..2ebed99ba5 --- /dev/null +++ b/.github/workflows/issue_comment.yml @@ -0,0 +1,34 @@ +name: Issue Comment + +on: + issue_comment: + types: [created] + +jobs: + notify: + runs-on: ubuntu-latest + permissions: {} + if: ${{ !github.event.issue.pull_request && !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) }} + steps: + - name: Run webhook curl command + env: + WEBHOOK_URL: ${{ secrets.SLACK_COMMENT_WEBHOOK_URL }} + BODY: ${{ toJson(github.event.comment.body) }} + COMMENT_URL: ${{github.event.comment.html_url}} + shell: bash + run: echo $BODY | xargs -I {} curl -s POST "$WEBHOOK_URL" -H "Content-Type:application/json" --data '{"body":"{}", "issue":"'$COMMENT_URL'"}' + + remove-pending-response-label: + runs-on: ubuntu-latest + permissions: + issues: write + if: ${{ !github.event.issue.pull_request && contains(github.event.issue.labels.*.name, 'pending-response') }} + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 + - name: remove unnecessary labels after closing + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_NUMBER: ${{ github.event.issue.number }} + run: | + gh issue edit $ISSUE_NUMBER --remove-label "pending-response" diff --git a/.github/workflows/issue_labeled.yml b/.github/workflows/issue_labeled.yml new file mode 100644 index 0000000000..74cac31820 --- /dev/null +++ b/.github/workflows/issue_labeled.yml @@ -0,0 +1,20 @@ +name: Issue Labeled +on: + issues: + types: [labeled] + +jobs: + remove-pending-triage-label: + runs-on: ubuntu-latest + if: ${{ contains(fromJSON('["question", "bug", "feature-request", "improvement"]'), github.event.label.name) }} + permissions: + issues: write + steps: + - name: Remove the pending-triage label + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_NUMBER: ${{ github.event.issue.number }} + REPOSITORY_NAME: ${{ github.event.repository.full_name }} + run: | + gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --remove-label "pending-triage" \ No newline at end of file diff --git a/.github/workflows/issue_opened.yml b/.github/workflows/issue_opened.yml new file mode 100644 index 0000000000..b3ccf57364 --- /dev/null +++ b/.github/workflows/issue_opened.yml @@ -0,0 +1,48 @@ +name: Issue Opened +on: + issues: + types: [opened] + +jobs: + notify: + runs-on: ubuntu-latest + permissions: {} + if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.issue.author_association) }} + steps: + - name: Run webhook curl command + env: + WEBHOOK_URL: ${{ secrets.SLACK_ISSUE_WEBHOOK_URL }} + ISSUE: ${{toJson(github.event.issue.title)}} + ISSUE_URL: ${{github.event.issue.html_url}} + USER: ${{github.event.issue.user.login}} + shell: bash + run: echo $ISSUE | sed 's/[^a-zA-Z0-9 &().,:]//g' | xargs -I {} curl -s POST "$WEBHOOK_URL" -H "Content-Type:application/json" --data '{"issue":"{}", "issueUrl":"'$ISSUE_URL'", "user":"'$USER'"}' + + add-pending-triage-label: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Add the pending-triage label + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_NUMBER: ${{ github.event.issue.number }} + REPOSITORY_NAME: ${{ github.event.repository.full_name }} + run: | + gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --add-label "pending-triage" + + maintainer-opened: + runs-on: ubuntu-latest + permissions: + issues: write + if: ${{ contains(fromJSON('["MEMBER", "OWNER"]'), github.event.issue.author_association) }} + steps: + - name: Post comment if maintainer opened. + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_NUMBER: ${{ github.event.issue.number }} + REPOSITORY_NAME: ${{ github.event.repository.full_name }} + run: | + gh issue comment $ISSUE_NUMBER --repo $REPOSITORY_NAME -b "This issue was opened by a maintainer of this repository; updates will be posted here. If you are also experiencing this issue, please comment here with any relevant information so that we're aware and can prioritize accordingly." \ No newline at end of file diff --git a/.github/workflows/notify_comments.yml b/.github/workflows/notify_comments.yml deleted file mode 100644 index f7eef52404..0000000000 --- a/.github/workflows/notify_comments.yml +++ /dev/null @@ -1,29 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: Notify Comments on PCR - -# Controls when the workflow will run -on: - # Triggers the workflow on comment events on closed, pending response and closing soon issues - issue_comment: - types: [created] - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "notify" - notify: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - if: ${{ !github.event.issue.pull_request && (github.event.issue.state == 'closed' || contains(github.event.issue.labels.*.name, 'pending-response') || contains(github.event.issue.labels.*.name, 'closing soon')) }} - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Runs a single command using the runners shell - - name: Run webhook curl command - env: - WEBHOOK_URL: ${{ secrets.SLACK_COMMENT_WEBHOOK_URL }} - BODY: ${{ toJson(github.event.comment.body) }} - COMMENT_URL: ${{github.event.comment.html_url}} - shell: bash - run: echo $BODY | xargs -I {} curl -s POST "$WEBHOOK_URL" -H "Content-Type:application/json" --data '{"body":"{}", "issue":"'$COMMENT_URL'"}' diff --git a/.github/workflows/notify_pull_request.yml b/.github/workflows/notify_pull_request.yml new file mode 100644 index 0000000000..419f4a8f6c --- /dev/null +++ b/.github/workflows/notify_pull_request.yml @@ -0,0 +1,19 @@ +name: Notify Pull Request + +on: + pull_request: + types: [opened, ready_for_review, reopened] + +jobs: + notify: + runs-on: ubuntu-latest + if: ${{ !github.event.draft }} + steps: + - name: Run webhook curl command + env: + WEBHOOK_URL: ${{ secrets.SLACK_PR_WEBHOOK_URL }} + URL: ${{ github.event.pull_request.html_url }} + TITLE: ${{ github.event.pull_request.title }} + USER: ${{ github.event.pull_request.user.login }} + shell: bash + run: curl -s POST "$WEBHOOK_URL" -H "Content-Type:application/json" --data "{\"url\":\"$URL\", \"title\":\"$TITLE\", \"user\":\"$USER\"}" diff --git a/.github/workflows/priority_bumper.yml b/.github/workflows/priority_bumper.yml deleted file mode 100644 index 775c3bf017..0000000000 --- a/.github/workflows/priority_bumper.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Projects priority automation -on: - issue_comment: - types: [created] - -jobs: - bump_to_p2: - runs-on: ubuntu-latest - if: ${{ github.event.issue.comments > 10 }} - steps: - - name: Bump to P2 - env: - GITHUB_TOKEN: ${{ secrets.PROJECT_WORKFLOW_TOKEN }} - PROJECT_ID: ${{ secrets.PROJECT_ID }} - ISSUE_ID: ${{ github.event.issue.node_id }} - FIELD_ID: ${{ secrets.PRIORITY_COL }} - FIELD_OPT_ID: ${{ secrets.P2_OPT_ID }} - shell: bash - run: curl -s POST https://api.github.com/graphql -H "Authorization:Bearer $GITHUB_TOKEN" --data '{"query":"mutation {updateProjectNextItemField(input:{projectId:\"${{ env.PROJECT_ID }}\" itemId:\"${{ env.ISSUE_ID }}\" fieldId:\"${{ env.FIELD_ID }}\" value:\"${{ env.FIELD_OPT_ID }}\"}) {projectNextItem {id}}}"}' > /dev/null - - bump_to_p1: - runs-on: ubuntu-latest - if: ${{ github.event.issue.comments > 15 }} - steps: - - name: Bump to P1 - env: - GITHUB_TOKEN: ${{ secrets.PROJECT_WORKFLOW_TOKEN }} - PROJECT_ID: ${{ secrets.PROJECT_ID }} - ISSUE_ID: ${{ github.event.issue.node_id }} - FIELD_ID: ${{ secrets.PRIORITY_COL }} - FIELD_OPT_ID: ${{ secrets.P1_OPT_ID }} - shell: bash - run: curl -s POST https://api.github.com/graphql -H "Authorization:Bearer $GITHUB_TOKEN" --data '{"query":"mutation {updateProjectNextItemField(input:{projectId:\"${{ env.PROJECT_ID }}\" itemId:\"${{ env.ISSUE_ID }}\" fieldId:\"${{ env.FIELD_ID }}\" value:\"${{ env.FIELD_OPT_ID }}\"}) {projectNextItem {id}}}"}' > /dev/null - \ No newline at end of file diff --git a/.github/workflows/project_automation.yml b/.github/workflows/project_automation.yml deleted file mode 100644 index 04d602cee7..0000000000 --- a/.github/workflows/project_automation.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Projects beta automation -on: - issues: - types: [opened, assigned, unassigned, labeled, unlabeled] - -jobs: - add_issue: - runs-on: ubuntu-latest - if: ${{ github.event.action == 'opened' }} - steps: - - name: Add to project - env: - GITHUB_TOKEN: ${{ secrets.PROJECT_WORKFLOW_TOKEN }} - PROJECT_ID: ${{ secrets.PROJECT_ID }} - ISSUE_ID: ${{ github.event.issue.node_id }} - shell: bash - run: | - curl -s POST https://api.github.com/graphql -H "Authorization:Bearer $GITHUB_TOKEN" --data '{"query":"mutation {addProjectNextItem(input:{projectId:\"${{ env.PROJECT_ID }}\" contentId:\"${{ env.ISSUE_ID }}\"}) {projectNextItem {id}}}"}' > /dev/null - - move_to_wip: - runs-on: ubuntu-latest - if: ${{ github.event.action == 'assigned' || contains(github.event.issue.labels.*.name, 'pending-response') || contains(github.event.issue.labels.*.name, 'closing soon') }} - steps: - - name: Move to WIP column - env: - GITHUB_TOKEN: ${{ secrets.PROJECT_WORKFLOW_TOKEN }} - PROJECT_ID: ${{ secrets.PROJECT_ID }} - ISSUE_ID: ${{ github.event.issue.node_id }} - FIELD_ID: ${{ secrets.STATUS_COL }} - FIELD_OPT_ID: ${{ secrets.WIP_OPT_ID }} - shell: bash - run: | - curl -s POST https://api.github.com/graphql -H "Authorization:Bearer $GITHUB_TOKEN" —data '{"query":"mutation {updateProjectNextItemField(input:{projectId:\"${{ env.PROJECT_ID }}\" itemId:\"${{ env.ISSUE_ID }}\" fieldId:\"${{ env.FIELD_ID }}\" value:\"${{ env.FIELD_OPT_ID }}\"}) {projectNextItem {id}}}"}' > /dev/null - - move_to_todo: - runs-on: ubuntu-latest - if: ${{ join(github.event.issue.assignees.*.login) == '' && !contains(github.event.issue.labels.*.name, 'pending-response') && !contains(github.event.issue.labels.*.name, 'closing soon') }} - steps: - - name: Move to Todo column - env: - GITHUB_TOKEN: ${{ secrets.PROJECT_WORKFLOW_TOKEN }} - PROJECT_ID: ${{ secrets.PROJECT_ID }} - ISSUE_ID: ${{ github.event.issue.node_id }} - FIELD_ID: ${{ secrets.STATUS_COL }} - FIELD_OPT_ID: ${{ secrets.TODO_OPT_ID }} - shell: bash - run: | - curl -s POST https://api.github.com/graphql -H "Authorization:Bearer $GITHUB_TOKEN" --data '{"query":"mutation {updateProjectNextItemField(input:{projectId:\"${{ env.PROJECT_ID }}\" itemId:\"${{ env.ISSUE_ID }}\" fieldId:\"${{ env.FIELD_ID }}\" value:\"${{ env.FIELD_OPT_ID }}\"}) {projectNextItem {id}}}"}' > /dev/null - - diff --git a/.github/workflows/publish_rollback.yml b/.github/workflows/publish_rollback.yml deleted file mode 100644 index 02e7fd249d..0000000000 --- a/.github/workflows/publish_rollback.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Publish Rollback Artifacts - -on: - workflow_dispatch: - -jobs: - publish_rollback: - runs-on: ubuntu-latest - permissions: - id-token: write - steps: - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 #2.2.0 - with: - role-to-assume: ${{ secrets.AMPLIFY_ANDROID_RELEASE_PUBLISHER_ROLE }} - aws-region: us-east-1 - - name: Start Maven Release Build - uses: aws-actions/aws-codebuild-run-build@d5a04846cedab61a0b7c897af0548af0d8fb14fb #1.0.12 - with: - project-name: AmplifyAndroid-ReleasePublisher-V2 \ No newline at end of file diff --git a/.github/workflows/release_pr_approval_count.yml b/.github/workflows/release_pr_approval_count.yml deleted file mode 100644 index 776846547c..0000000000 --- a/.github/workflows/release_pr_approval_count.yml +++ /dev/null @@ -1,30 +0,0 @@ -# Checks the number of a approvals for any pull requests from bump_version->main where the PR title starts with release -# This should be setup as a protection rule on the main branch. PRs coming from other branches will be exempt from this rule -name: Pull request approval checks -on: - pull_request_review: - branches: - - main -jobs: - count_approvals: - runs-on: ubuntu-latest - # This restricts which PRs this workflow applies to. - if: ${{ github.event_name == 'pull_request_review' - && github.event.pull_request.head.ref == 'bump_version' - && startsWith(github.event.pull_request.title, 'release:') - }} - steps: - - uses: actions/github-script@ffc2c79a5b2490bd33e0a41c1de74b877714d736 # v3 - id: get_approval_count - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - const reviews = await github.pulls.listReviews({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number, - }); - const approvals = reviews.data.filter(review => review.state==='APPROVED').length; - if (approvals < 2) { - core.setFailed('Not enough approvals yet :('); - } diff --git a/.github/workflows/rollback_release.yml b/.github/workflows/rollback_release.yml index e617aeaf98..faa206d4d2 100644 --- a/.github/workflows/rollback_release.yml +++ b/.github/workflows/rollback_release.yml @@ -11,24 +11,23 @@ on: required: true new_version: description: 'The new version number (e.g. 2.9.3)' + required: true - +env: + AWS_REGION: "us-east-1" + BRANCH_FROM: ${{ inputs.branch_from }} + DEPRECATED_VERSION: ${{ inputs.deprecated_version }} + NEW_VERSION: ${{ inputs.new_version }} + CI_COMMIT_MESSAGE: Re-release v${{ inputs.branch_from }} as v${{ inputs.new_version }} + ROLLBACK_BRANCH: rollback_${{ inputs.deprecated_version }} + NEW_TAG: release_v${{ inputs.new_version }} jobs: - rollback-release: + create-rollback-branch: runs-on: ubuntu-latest - env: - AWS_REGION: "us-east-1" - BRANCH_FROM: ${{ inputs.branch_from }} - DEPRECATED_VERSION: ${{ inputs.deprecated_version }} - NEW_VERSION: ${{ inputs.new_version }} - CI_COMMIT_MESSAGE: Re-release v${{ inputs.branch_from }} as v${{ inputs.new_version }} - ROLLBACK_BRANCH: rollback_${{ inputs.deprecated_version }} - NEW_TAG: release_v${{ inputs.new_version }} permissions: id-token: write contents: write - actions: write steps: - name: Checkout Source Code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 @@ -41,7 +40,7 @@ jobs: run: | git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com git config --global user.name github-actions[bot] - sed -i 's/POM_VERSION=${{ env.BRANCH_FROM }}/POM_VERSION=${{ env.NEW_VERSION }}/g' gradle.properties + sed -i 's/VERSION_NAME=${{ env.BRANCH_FROM }}/VERSION_NAME=${{ env.NEW_VERSION }}/g' gradle.properties echo -e '## [Release ${{ env.NEW_VERSION }}](https://github.com/${{ github.repository }}/releases/tag/${{ env.NEW_TAG }})\n\nThis is a re-release of version ${{ env.BRANCH_FROM }}. Use this instead of version ${{ env.DEPRECATED_VERSION }}.\n' | cat - CHANGELOG.md > temp && mv temp CHANGELOG.md git add gradle.properties git add CHANGELOG.md @@ -50,16 +49,20 @@ jobs: run: git tag "${{ env.NEW_TAG }}" - name: Push Changes run: git push --atomic origin ${{ env.ROLLBACK_BRANCH }} ${{ env.NEW_TAG }} - - name: Run Publish - uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 + + publish-rollback: + needs: create-rollback-branch + runs-on: ubuntu-latest + permissions: + id-token: write + steps: + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 #2.2.0 + with: + role-to-assume: ${{ secrets.AMPLIFY_ANDROID_RELEASE_PUBLISHER_ROLE }} + aws-region: ${{ env.AWS_REGION }} + - name: Start Maven Release Build + uses: aws-actions/aws-codebuild-run-build@2a49e1faf172677d80ce658678e9ff8bd2737d74 #1.0.15 with: - # The aws-codebuild-run-build action automatically passes the source version that the workflow - # is run on to Codebuild, and there is no override option. In order to run the Codebuild - # release with our newly-created tag version we dispatch another workflow on that tag. - script: | - github.rest.actions.createWorkflowDispatch({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: 'rollback_publish.yml', - ref: "${{ env.NEW_TAG }}", - }) + project-name: AmplifyAndroid-ReleasePublisher-V2 + source-version-override: ${{ env.NEW_TAG }} diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 04d8266a43..80a2c0abf4 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -31,16 +31,11 @@