Skip to content

Commit

Permalink
Use pull_requeset_target with paths to target branches with changes t…
Browse files Browse the repository at this point in the history
…o drainpipe-dev.
  • Loading branch information
davereid committed Apr 26, 2024
1 parent 13e23ce commit 36d5798
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions .github/workflows/DrainpipeDev.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: Push Drainpipe Dev Package

on:
pull_request_target:
paths:
- 'drainpipe-dev/**'
push:
branches:
'**'
- 'main'
tags:
- 'v*'
delete:
Expand All @@ -23,19 +26,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Get branch information
id: branch-names
uses: tj-actions/branch-names@v8

- name: For non-default branch and non-tags, check if drainpipe-dev was changed
if: ${{ steps.branch-names.outputs.is_default == 'false' || steps.branch-names.outputs.is_tag == 'false' }}
id: files-changed
uses: tj-actions/changed-files@v44
with:
files: 'drainpipe-dev/**'

- name: Add drainpipe-dev deploy key in order to run git clone
if: ${{ steps.branch-names.outputs.is_default == 'true' || steps.branch-names.outputs.is_tag == 'true' || steps.files-changed.outputs.any_changed == 'true' }}
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DRAINPIPE_DEV_DEPLOY_KEY }}
Expand All @@ -44,19 +35,17 @@ jobs:
# Commits made by the https://github.com/apps/lullabot-drainpipe application.
# @see https://github.com/orgs/community/discussions/24664
- name: Create git checkout of drainpipe-dev
if: ${{ steps.branch-names.outputs.is_default == 'true' || steps.branch-names.outputs.is_tag == 'true' || steps.files-changed.outputs.any_changed == 'true' }}
working-directory: drainpipe-dev
run: |
git init
git branch -m ${{ github.ref_name }}
git remote add origin [email protected]:Lullabot/drainpipe-dev.git
git fetch origin
git reset --mixed origin/${{ github.ref_name }} || git reset --mixed origin/${{ steps.branch-names.outputs.default_branch }}
git reset --mixed origin/${{ github.ref_name }} || git reset --mixed origin/main
git config user.name "Lullabot-Drainpipe[bot]"
git config user.email "157769597+Lullabot-Drainpipe[bot]@users.noreply.github.com"
- name: Push branch to drainpipe-dev
if: ${{ steps.branch-names.outputs.is_default == 'true' || steps.branch-names.outputs.is_tag == 'true' || steps.files-changed.outputs.any_changed == 'true' }}
working-directory: drainpipe-dev
run: |
git add -A
Expand All @@ -67,7 +56,7 @@ jobs:
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}

- name: Push tag to drainpipe-dev
if: ${{ steps.branch-names.outputs.is_tag == 'true' }}
if: ${{ startsWith(github.ref, 'refs/tags/') }}
working-directory: drainpipe-dev
run: |
git tag ${{ github.ref_name }}
Expand Down

0 comments on commit 36d5798

Please sign in to comment.