Skip to content

Commit

Permalink
Merge pull request #6 from draios/SITEOPS-1328-Remove-file-from-upsteam
Browse files Browse the repository at this point in the history
feat(action.yml): add remove from upstream feature
  • Loading branch information
massimoschembri authored Jan 3, 2024
2 parents dbbfd8c + 62aa21b commit 7837e15
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/test-local-action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
name: Test local action without fixed version
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Test local action
id: local-action
uses: ./
Expand All @@ -25,7 +25,7 @@ jobs:
name: Test local action with fixed version
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Test local action
id: local-action
uses: ./
Expand All @@ -40,6 +40,28 @@ jobs:
tag_minor: ${{ steps.local-action.outputs.tag_minor }}
tag_patch: ${{ steps.local-action.outputs.tag_patch }}

local_test_upstream_remove_files:
runs-on: ubuntu-latest
name: Test local action with upstream_remove_files set
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test local action
id: local-action
uses: ./
with:
upstream_repo: sysdiglabs/kube-psp-advisor
local_patch_dir: tests/sysdiglabs/kube-psp-advisor
upstream_ref: master
upstream_remove_files: |
version
comparator/comparator.go
- name: Assert that files are removed
id: test-remove
run: |-
! [[ -f upstream/version ]] && ! [[ -f upstream/comparator/comparator.go ]]
shell: bash

print_results:
runs-on: ubuntu-latest
name: Print test results
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Checkout the ref (or latest) upstream version and apply one or more patch files

- `upstream_ref`: The upstream ref, can be: branch, tag, sha, if not provided last semver tag will be grabbed automatically
- `upstream_tag_regex`: Regex to use while checking the last upstream versions
- `upstream_remove_files`: Line separated list of files to remove from upstream repository

## Outputs

Expand Down
14 changes: 14 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ inputs:
description: "Directory of the patch files, must end with .patch"
required: true

upstream_remove_files:
description: "Line separated list of files to remove from upstream repository"
required: false

runs:
using: "composite"
steps:
Expand Down Expand Up @@ -91,3 +95,13 @@ runs:
env:
PATCHDIR: ${{ inputs.local_patch_dir }}
run: for p in patch/${PATCHDIR}/*.patch; do patch -d upstream/ -p1 < $p; done

- name: Remove from upstream
id: upstream_remove_files
if: ${{ inputs.upstream_remove_files != '' }}
shell: bash
run: |
FILES=$(echo "${{ inputs.upstream_remove_files }}" | tr '\n' ' ')
for file in ${FILES}; do
[[ -f "upstream/${file}" ]] && rm -v "upstream/${file}" || true
done

0 comments on commit 7837e15

Please sign in to comment.