-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add org parameter and adding files
- Loading branch information
1 parent
c6278b8
commit 98156ca
Showing
7 changed files
with
153 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: 'addingFiles' | ||
|
||
description: 'Adds files to git' | ||
|
||
inputs: | ||
files: | ||
description: File or folder to add | ||
required: true | ||
commit-message: | ||
description: Commit message when raising pr | ||
default: "chore: adding files" | ||
required: false | ||
branch-name: | ||
description: Branch name when raising pr | ||
default: chore/add-files | ||
required: false | ||
title: | ||
description: Title of raised pr | ||
default: 'chore: adding files' | ||
required: false | ||
body: | ||
description: Body of raised pr | ||
default: Adding files | ||
required: false | ||
labels: | ||
description: Lavels for pr (separated by new line) | ||
default: automated pr | ||
required: false | ||
token: | ||
description: Access token to push and raise pr | ||
required: true | ||
|
||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Checkout scaffolder repo | ||
uses: actions/checkout@v4 | ||
- name: Check file or folder exists | ||
run: | | ||
${{ github.action_path }}/lintInput.sh ${{ inputs.files }} | ||
shell: bash | ||
- name: Checkout target repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ inputs.repository }} | ||
ref: main | ||
fetch-depth: 0 | ||
token: ${{ inputs.token }} | ||
- name: Configure git | ||
run: | | ||
git config user.name 'Github Action' | ||
git config user.email '[email protected]' | ||
- name: Checkout branch and copy over files | ||
run: | | ||
git checkout -b ${{ inputs.branch-name }} | ||
cd . | ||
ls | ||
cp -R /home/runner/work/repo-scaffolder/${{ inputs.files }} /home/runner/work/${{ inputs.repository }}/ | ||
cd /home/runner/work/${{ inputs.repository }}/ | ||
ls | ||
- name: Add to git | ||
run: | | ||
git add ${{ inputs.files }} | ||
- name: Create pull request | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ inputs.token }} | ||
commit-message: ${{ inputs.commit-message }} | ||
branch: ${{ inputs.branch-name }} | ||
delete-branch: true | ||
title: ${{ inputs.title }} | ||
body: | | ||
${{ inputs.body }} | ||
labels: | | ||
${{ inputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
location=$1 | ||
|
||
if test -f $location; then | ||
echo "File exists." | ||
elif test -d $location; then | ||
echo "Directory exists." | ||
else | ||
echo "error: file or direcoty not found: " $1 >&2; exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Add files to repos | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
query: | ||
description: 'Query for github API' | ||
default: 'topic:x' | ||
required: true | ||
org: | ||
description: 'Org to search for repos in' | ||
default: 'DSACMS' | ||
required: true | ||
files: | ||
description: 'File or folders to add' | ||
default: 'tier1/LICENSE' | ||
required: true | ||
|
||
env: | ||
repo: "" | ||
|
||
jobs: | ||
find-repos: | ||
runs-on: ubuntu-latest | ||
name: Find repos and generate matrix | ||
steps: | ||
- name: Checkout Action | ||
uses: actions/checkout@v4 | ||
- name: Find repos | ||
uses: ./.github/findRepos | ||
with: | ||
query: ${{ github.event.inputs.query }} | ||
org: ${{ github.event.inputs.org }} | ||
token: ${{ secrets.pat }} | ||
outputs: | ||
matrix: ${{ env.repo }} | ||
|
||
add-files: | ||
runs-on: ubuntu-latest | ||
name: Add files | ||
needs: [find-repos] | ||
strategy: | ||
matrix: | ||
repo: ${{ fromJSON(needs.find-repos.outputs.matrix ) }} | ||
steps: | ||
- name: Checkout Action | ||
uses: actions/checkout@v4 | ||
- name: Update file | ||
uses: ./.github/addingFile | ||
with: | ||
repository: ${{ matrix.repo }} | ||
files: ${{ github.event.inputs.files }} | ||
token: ${{ secrets.pat }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters