Skip to content

build: adds delivery tasks #196

build: adds delivery tasks

build: adds delivery tasks #196

name: Process Issue Attachments

Check failure on line 1 in .github/workflows/process-issue-zip.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/process-issue-zip.yml

Invalid workflow file

(Line: 9, Col: 9): Unexpected symbol: ')'. Located at position 45 within expression: contains(github.event.comment.body, '.zip)')) && contains(fromJSON('["pftg"]'), github.event.comment.user.login)
on:
issue_comment:
types: [ created ]
jobs:
handle-upload:
if: |
contains(github.event.comment.body, '.zip)')) &&
contains(fromJSON('["pftg"]'), github.event.comment.user.login)
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
steps:
- name: Checkout repo
uses: actions/checkout@v5
- name: Parse comment
id: parse
run: |
ZIP_URL=$(echo "${{ github.event.comment.body }}" |
grep -oP '\[.*?\]\((https?://.*?\.zip)\)' |
grep -oP '(https?://.*?\.zip)')
echo "url=$ZIP_URL" >> $GITHUB_OUTPUT
echo "issue=${{ github.event.issue.number }}" >> $GITHUB_OUTPUT
- name: Download and process ZIP
if: steps.parse.outputs.url != ''
run: |
wget "${{ steps.parse.outputs.url }}" -O upload.zip
mkdir -p "tmp/posts/${{ steps.parse.outputs.issue }}"
unzip upload.zip -d "tmp/posts/${{ steps.parse.outputs.issue }}"
rm upload.zip
- name: Create branch and commit files
if: steps.parse.outputs.url != ''
run: |
git config --global user.name "Issue Processor"
git config --global user.email "actions@github.com"
# Create a new branch
BRANCH_NAME="add-files-issue-${{ steps.parse.outputs.issue }}"
git checkout -b $BRANCH_NAME
git add .
git commit -m "Add files from issue #${{ steps.parse.outputs.issue }}"
git push origin $BRANCH_NAME
- name: Create Pull Request
if: steps.parse.outputs.url != ''
id: create_pr
env:
GH_TOKEN: ${{ github.token }}
run: |
pr_url=$(gh pr create --base master \
--title "Add files from issue #${{ steps.parse.outputs.issue }}" \
--body "This PR adds files uploaded in issue #${{ steps.parse.outputs.issue }}. \
Automatically created by the Process Issue Attachments workflow.")
echo "pr_url=$pr_url" >> $GITHUB_OUTPUT
- name: Update issue
if: steps.parse.outputs.issue != '' && steps.create_pr.outputs.pr_url != ''
env:
GH_TOKEN: ${{ github.token }}
run: |
gh issue comment ${{ steps.parse.outputs.issue }} \
--body "✅ Files processed and a Pull Request has been created! \
View PR: ${{ steps.create_pr.outputs.pr_url }}"