diff --git a/.github/actions/sync-athena/action.yml b/.github/actions/sync-athena/action.yml new file mode 100644 index 000000000..619425679 --- /dev/null +++ b/.github/actions/sync-athena/action.yml @@ -0,0 +1,93 @@ +name: Run sync-athena +description: Pull gitlab.espressif.cn:5050/idf/sync-athena and run one sync mode. + +inputs: + mode: + description: issue_to_task, comment_to_task, or pr_to_comment + required: true + issue_number: + description: Backfill issue number(s); used only for workflow_dispatch + required: false + default: "" + image: + description: sync-athena image built by the idf/sync-athena GitLab pipeline + required: false + default: gitlab.espressif.cn:5050/idf/sync-athena:latest + ticket_prefix: + description: Ticket key prefix; issue #42 becomes -42 + required: false + default: IEP + editors: + description: Comma-separated editor emails + required: false + default: "" + co_authors: + description: Comma-separated co-author emails + required: false + default: "" + email_domain: + description: Domain used to expand bare usernames in editors/co_authors + required: false + default: espressif.com + athena_project_uuid: + description: Athena project UUID + required: true + athena_db_path: + description: Athena database path (project/proj_.db) + required: true + athena_base_url: + description: Athena server URL + required: true + athena_token: + description: Athena bot token (nodes:read, nodes:write) + required: true + registry_username: + description: GitLab registry username + required: true + registry_token: + description: GitLab token with read_registry on idf/sync-athena + required: true + +runs: + using: composite + steps: + - name: Log in to GitLab Container Registry + uses: docker/login-action@v3 + with: + registry: gitlab.espressif.cn:5050 + username: ${{ inputs.registry_username }} + password: ${{ inputs.registry_token }} + + - name: Pull sync-athena image + shell: bash + env: + IMAGE: ${{ inputs.image }} + run: docker pull "$IMAGE" + + - name: Run sync-athena + shell: bash + env: + IMAGE: ${{ inputs.image }} + MODE: ${{ inputs.mode }} + REPO: ${{ github.repository }} + ISSUE_NUMBER: ${{ inputs.issue_number }} + EVENT_PATH: ${{ github.event_path }} + ATHENA_TICKET_PREFIX: ${{ inputs.ticket_prefix }} + ATHENA_EDITORS: ${{ inputs.editors }} + ATHENA_CO_AUTHORS: ${{ inputs.co_authors }} + ATHENA_EMAIL_DOMAIN: ${{ inputs.email_domain }} + ATHENA_PROJECT_UUID: ${{ inputs.athena_project_uuid }} + ATHENA_DB_PATH: ${{ inputs.athena_db_path }} + ATHENA_BASE_URL: ${{ inputs.athena_base_url }} + ATHENA_TOKEN: ${{ inputs.athena_token }} + GITHUB_TOKEN: ${{ github.token }} + run: | + docker run --rm \ + -v "${RUNNER_TEMP}:${RUNNER_TEMP}" \ + -v "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" \ + -e MODE -e REPO -e EVENT_PATH -e ISSUE_NUMBER \ + -e ATHENA_PROJECT_UUID -e ATHENA_DB_PATH -e ATHENA_BASE_URL -e ATHENA_TOKEN \ + -e ATHENA_TICKET_PREFIX -e ATHENA_EDITORS -e ATHENA_CO_AUTHORS \ + -e ATHENA_EMAIL_DOMAIN \ + -e GITHUB_TOKEN -e GITHUB_OUTPUT \ + "$IMAGE" diff --git a/.github/workflows/sync-athena.yml b/.github/workflows/sync-athena.yml new file mode 100644 index 000000000..5ab8d7e6d --- /dev/null +++ b/.github/workflows/sync-athena.yml @@ -0,0 +1,93 @@ +name: 🔷 Sync to Athena + +run-name: > + Sync to Athena - + ${{ github.event_name == 'pull_request' && 'New Pull Request' || + github.event_name == 'issue_comment' && 'New Comment' || + github.event_name == 'issues' && 'New Issue' || + github.event_name == 'workflow_dispatch' && 'Manual Sync' }} + +on: + issues: + types: [opened, edited, reopened, closed] + issue_comment: + types: [created, edited] + pull_request: + types: [opened, reopened, ready_for_review] + workflow_dispatch: + inputs: + issue-numbers: + description: "Issue numbers to backfill (comma-separated)" + required: true + +permissions: {} + +jobs: + issue-to-task: + if: github.event_name == 'issues' || github.event_name == 'workflow_dispatch' + name: Create or update Athena task from GitHub issue + runs-on: ubuntu-latest + permissions: + contents: read + issues: write + steps: + - uses: actions/checkout@v6 + - name: Sync issue to Athena + uses: ./.github/actions/sync-athena + with: + mode: issue_to_task + issue_number: ${{ inputs.issue-numbers }} + ticket_prefix: ${{ vars.ATHENA_TICKET_PREFIX || 'IEP' }} + editors: ${{ vars.ATHENA_EDITORS }} + co_authors: ${{ vars.ATHENA_CO_AUTHORS }} + athena_project_uuid: ${{ vars.ATHENA_PROJECT_UUID }} + athena_db_path: ${{ vars.ATHENA_DB_PATH }} + athena_base_url: ${{ secrets.ATHENA_BASE_URL }} + athena_token: ${{ secrets.ATHENA_TOKEN }} + registry_username: ${{ vars.SYNC_ATHENA_REGISTRY_USERNAME }} + registry_token: ${{ secrets.SYNC_ATHENA_REGISTRY_TOKEN }} + + comment-to-task: + if: github.event_name == 'issue_comment' + name: Append issue/PR comment to matching Athena task + runs-on: ubuntu-latest + permissions: + contents: read + issues: read + pull-requests: read + steps: + - uses: actions/checkout@v6 + - name: Sync comment to Athena + uses: ./.github/actions/sync-athena + with: + mode: comment_to_task + ticket_prefix: ${{ vars.ATHENA_TICKET_PREFIX || 'IEP' }} + athena_project_uuid: ${{ vars.ATHENA_PROJECT_UUID }} + athena_db_path: ${{ vars.ATHENA_DB_PATH }} + athena_base_url: ${{ secrets.ATHENA_BASE_URL }} + athena_token: ${{ secrets.ATHENA_TOKEN }} + registry_username: ${{ vars.SYNC_ATHENA_REGISTRY_USERNAME }} + registry_token: ${{ secrets.SYNC_ATHENA_REGISTRY_TOKEN }} + + pr-to-task: + if: > + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name == github.repository + name: Link PR to its Athena task + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + steps: + - uses: actions/checkout@v6 + - name: Sync PR to Athena + uses: ./.github/actions/sync-athena + with: + mode: pr_to_comment + ticket_prefix: ${{ vars.ATHENA_TICKET_PREFIX || 'IEP' }} + athena_project_uuid: ${{ vars.ATHENA_PROJECT_UUID }} + athena_db_path: ${{ vars.ATHENA_DB_PATH }} + athena_base_url: ${{ secrets.ATHENA_BASE_URL }} + athena_token: ${{ secrets.ATHENA_TOKEN }} + registry_username: ${{ vars.SYNC_ATHENA_REGISTRY_USERNAME }} + registry_token: ${{ secrets.SYNC_ATHENA_REGISTRY_TOKEN }}