Skip to content

Commit c59fbd2

Browse files
authored
Merge pull request #78 from tighten/adc/update-gh-actions
Update GitHub actions
2 parents b4c5412 + d89282d commit c59fbd2

File tree

4 files changed

+51
-36
lines changed

4 files changed

+51
-36
lines changed

app/Commands/GitHubActionsCommand.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,18 @@ class GitHubActionsCommand extends Command
1515
public function handle(): int
1616
{
1717
$branch = $this->anticipate('What is the name of your primary branch?', ['main', 'develop', 'master'], 'main');
18-
$phpVersion = $this->anticipate('What PHP version do you want to use?', ['8.1', '8.0'], '8.1');
18+
$commit = $this->choice('Would you like the action to automatically commit fixes?', ['yes', 'no'], 1);
1919

20-
$workflow = file_get_contents(__DIR__ . '/../../stubs/github-actions/lint.yml');
20+
$workflowName = $commit === 'yes' ? 'duster-fix' : 'duster-lint';
2121

22-
$workflow = str_replace(
23-
['YOUR_BRANCH_NAME', 'YOUR_PHP_VERSION'],
24-
[$branch, $phpVersion],
25-
$workflow
26-
);
22+
$workflow = file_get_contents(__DIR__ . "/../../stubs/github-actions/{$workflowName}.yml");
23+
$workflow = str_replace('YOUR_BRANCH_NAME', $branch, $workflow);
2724

2825
if (! is_dir(getcwd() . '/.github/workflows')) {
2926
mkdir(getcwd() . '/.github/workflows', 0777, true);
3027
}
3128

32-
file_put_contents(getcwd() . '/.github/workflows/lint.yml', $workflow);
29+
file_put_contents(getcwd() . "/.github/workflows/{$workflowName}.yml", $workflow);
3330

3431
$this->success('GitHub Actions added');
3532

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Duster Fix
2+
3+
on:
4+
push:
5+
branches: [ YOUR_BRANCH_NAME ]
6+
pull_request:
7+
8+
jobs:
9+
duster:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
ref: ${{ github.head_ref }}
19+
20+
- name: "Duster Fix"
21+
uses: tighten/duster-action@v1
22+
with:
23+
args: fix
24+
25+
- uses: stefanzweifel/git-auto-commit-action@v4
26+
with:
27+
commit_message: Dusting
28+
commit_user_name: GitHub Action
29+
commit_user_email: actions@github.com
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Duster Lint
2+
3+
on:
4+
push:
5+
branches: [ YOUR_BRANCH_NAME ]
6+
pull_request:
7+
8+
jobs:
9+
duster:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: "Duster Lint"
15+
uses: tighten/duster-action@v1
16+
with:
17+
args: lint

stubs/github-actions/lint.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)