chore: update to dynamically generate json file (#3041)
* update to improve speed of filing PR
* Revert "update to improve speed of filing PR"
This reverts commit 83c177ed77
.
* remove and ignore local event branch file
* add bash script to dynamically create local git branch file
* update documentation
This commit is contained in:
Родитель
f8a7ace22b
Коммит
605a9a30d1
|
@ -9,34 +9,39 @@ Required to run GitHub Actions on VMs. Choose your preferred Docker setup https:
|
|||
Required to run GitHub Actions locally.
|
||||
|
||||
```bash
|
||||
$ brew install nektos/tap/act
|
||||
brew install nektos/tap/act
|
||||
```
|
||||
|
||||
### 3. Install Azure CLI
|
||||
Required to integrate GitHub Actions and Azure.
|
||||
|
||||
```bash
|
||||
$ azure login
|
||||
azure login
|
||||
```
|
||||
|
||||
## Configure
|
||||
The `.actrc` file contains the default configuration and run methods. The `./.github/workflows/testing/push.json` file contains the default GitHub events to run.
|
||||
1. The `.actrc` file contains the default configuration and run methods.
|
||||
2. Run this Bash script `ci-act-event.sh` to dynamically generate the required configuration file for Act. Two questions will be asked to collect the local git branch name and GitHub event. An example might look like `.github/workflows/testing/push.json` where "push" is the github.event to trigger a GitHub Action against the branch named inside that same file. This file is `.gitignored` so it will need regenerated for testing.
|
||||
|
||||
Update the "ref" values in `./.github/workflows/testing/push.json` to point to the local git branch to test. Then perform the following to execute against that branch when running `act`.
|
||||
```bash
|
||||
cd .github/workflows/testing
|
||||
bash ci-act-event.sh
|
||||
```
|
||||
|
||||
A new file `{some-name}.json` will be generated inside `/testing/`. This is the local git branch that `Act` will run.
|
||||
|
||||
Run the event from the `/testing/*` folder as indicated with `-W` or `--workflows` arguments.
|
||||
|
||||
```bash
|
||||
$ act -e `./.github/workflows/testing/push.json` -W "./.github/workflows/testing/"
|
||||
$ act -e `.github/workflows/testing/${github_event}.json` -W "./.github/workflows/testing/"
|
||||
```
|
||||
|
||||
## Test
|
||||
`./.github/workflows/testing/ci-daily-local.yml` is used to test locally CI settings.
|
||||
|
||||
```bash
|
||||
$ act -j build_local_linux -e "./.github/workflows/testing/push.json" -W "./.github/workflows/testing/"
|
||||
$ act -j build_local_linux -e "./.github/workflows/testing/${github_event}.json" -W "./.github/workflows/testing/"
|
||||
```
|
||||
|
||||
## Cleanup
|
||||
When installing packages on docker instances, if versions change, it's important to kill the docker instance and rebuild.
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo " ------------------------------------------------------------------------------------------------ "
|
||||
echo "| This script will dynamically create an event.json file for use by Nektos/Act in testing GitHub |"
|
||||
echo "| Actions locally. |"
|
||||
echo " -------------------------------------------------------------------------------------------------"
|
||||
|
||||
# Ask for Branch Name
|
||||
echo -n "Enter git branch name? "
|
||||
read branch_name
|
||||
|
||||
# Ask for Event Type
|
||||
echo -n "Enter the GitHub Event to trigger the GitHub Action? "
|
||||
read github_event
|
||||
|
||||
# Combine user inputs into the json template
|
||||
# Set contents of the file to be overwritten
|
||||
echo '{
|
||||
"push": {
|
||||
"head": {
|
||||
"ref": "'$branch_name'"
|
||||
},
|
||||
"base": {
|
||||
"ref": "'$branch_name'"
|
||||
}
|
||||
}
|
||||
}' >& $github_event.json
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"push": {
|
||||
"head": {
|
||||
"ref": "users/awentzel/test-prettier-failure"
|
||||
},
|
||||
"base": {
|
||||
"ref": "users/awentzel/test-prettier-failure"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -69,4 +69,7 @@ sites/website/i18n/
|
|||
docs/en/packages/*/README.md
|
||||
|
||||
# TypeDoc generated subsites
|
||||
docs/en/packages/*/api/
|
||||
docs/en/packages/*/api/
|
||||
|
||||
# GitHub Actions Local Testing
|
||||
.github/workflows/testing/*.json
|
||||
|
|
Загрузка…
Ссылка в новой задаче