github / github/lock

PR lifetime lock

Đang mở
#23 4 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
58
Fork
11
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I can't get this to work with headless mode and PR lifetime lock. The unlock would trigger for any PR that was closed and because the lock was locked using headless mode, there is nothing that ties the lock to the pull-request.

```yaml
name: deploy

on:
issue_comment:
types: [created]
pull_request:
types: [closed]

permissions:
pull-requests: write
contents: write

jobs:
ilock:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request }}
steps:
- name: ilock
uses: github/lock@v2.1.1
with:
lock_trigger: /lock
unlock_trigger: /unlock
lock_info_alias: /wcid
unlock:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }}
steps:
- name: unlock
uses: github/lock@v2.1.1
with:
mode: unlock
deploy:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '/deploy') }}
steps:
- name: acknowledge
uses: actions/github-script@v6
with:
script: |
github.rest.reactions.createForIssueComment({
comment_id: context.payload.comment.id,
owner: context.repo.owner,
repo: context.repo.repo,
content: 'eyes',
});

- name: lock
id: lock
uses: github/lock@v2.1.1
with:
mode: check

- name: locked_comment
uses: actions/github-script@v6
if: ${{ steps.lock.outputs.locked == 'true' && steps.lock.outputs.created_by != github.actor }}
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "This repo is currently locked by ${{ steps.lock.outputs.created_by }}. Please wait for them to finish before trying again."
});

- name: acquire_lock
uses: github/lock@v2.1.1
if: ${{ steps.lock.outputs.locked == 'false' }}
with:
mode: lock

- name: deploy
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Deploying!"
});

- name: success
uses: actions/github-script@v6
if: ${{ success() }}
with:
script: |
github.rest.reactions.createForIssueComment({
comment_id: context.payload.comment.id,
owner: context.repo.owner,
repo: context.repo.repo,
content: '+1',
});

- name: failure
uses: actions/github-script@v6
if: ${{ failure() }}
with:
script: |
github.rest.reactions.createForIssueComment({
comment_id: context.payload.comment.id,
owner: context.repo.owner,
repo: context.repo.repo,
content: '-1',
});
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start with the workflow configuration in the issue and inspect how github/lock@v2.1.1 records and checks locks in headless mode. Reproduce the issue using the issue_comment and pull_request closed events, then verify that closing one pull request unlocks only the lock associated with that pull request.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
github-actions, javascript
Lĩnh vực
ci-cd, devops
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.