From 83390f309e1dcabf7a92a299940641db3895702d Mon Sep 17 00:00:00 2001 From: "Simen A. W. Olsen" Date: Wed, 17 Mar 2021 13:58:04 +0100 Subject: [PATCH] ci: Automatically update dist files on every push (#119) --- .github/husky/pre-commit | 2 +- .github/workflows/pull_request.yml | 25 +++++++++++++++++++ .github/workflows/smoke_test_cli_version.yml | 2 ++ .github/workflows/test.yml | 6 +++++ .github/workflows/update_dist.yml | 20 +++++++++++++++ .../workflows/workflow_dotnet_application.yml | 2 ++ .github/workflows/workflow_go_application.yml | 2 ++ .../workflows/workflow_nodejs_application.yml | 2 ++ .../workflows/workflow_python_application.yml | 2 ++ package.json | 5 ---- 10 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/pull_request.yml create mode 100644 .github/workflows/update_dist.yml diff --git a/.github/husky/pre-commit b/.github/husky/pre-commit index 70c3f396..d2ae35e8 100755 --- a/.github/husky/pre-commit +++ b/.github/husky/pre-commit @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -yarn build && git add dist/* && yarn lint-staged +yarn lint-staged diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 00000000..7384c072 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,25 @@ +name: Check for updated dist files +on: + pull_request: + +jobs: + check-if-dist-changed: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: dorny/paths-filter@v2 + id: changes + with: + filters: | + dist: + - 'dist/**' + - uses: mshick/add-pr-comment@v1 + if: steps.changes.outputs.dist == 'true' + with: + message: | + Hi 👋 + + Thank you for this contribution! + Due to security reasons, we only allow updating the `dist/**` files with our own workflows. + repo-token: ${{ secrets.PULUMI_BOT_TOKEN }} + repo-token-user-login: pulumi-bot diff --git a/.github/workflows/smoke_test_cli_version.yml b/.github/workflows/smoke_test_cli_version.yml index 91dacc93..0f778a83 100644 --- a/.github/workflows/smoke_test_cli_version.yml +++ b/.github/workflows/smoke_test_cli_version.yml @@ -31,6 +31,8 @@ jobs: working-directory: .github/test-stacks/dotnet env: PULUMI_CONFIG_PASSPHRASE: not-a-secret + - run: yarn install + - run: yarn build - uses: ./ env: PULUMI_CONFIG_PASSPHRASE: not-a-secret diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3dff160b..1f47873c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,6 +29,8 @@ jobs: working-directory: .github/test-stacks/golang env: PULUMI_CONFIG_PASSPHRASE: not-a-secret + - run: yarn install + - run: yarn build - uses: ./ if: always() id: pulumi @@ -55,6 +57,8 @@ jobs: working-directory: .github/test-stacks/golang env: PULUMI_CONFIG_PASSPHRASE: not-a-secret + - run: yarn install + - run: yarn build - uses: ./ if: always() env: @@ -80,6 +84,8 @@ jobs: working-directory: .github/test-stacks/golang env: PULUMI_CONFIG_PASSPHRASE: not-a-secret + - run: yarn install + - run: yarn build - uses: ./ if: always() env: diff --git a/.github/workflows/update_dist.yml b/.github/workflows/update_dist.yml new file mode 100644 index 00000000..794e99fd --- /dev/null +++ b/.github/workflows/update_dist.yml @@ -0,0 +1,20 @@ +name: Update dist files +on: + push: + branches: + - main + - master + +jobs: + update-dist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: yarn install + - run: yarn build + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + file_pattern: dist/** + commit_message: 'chore(dist): Update dist [automated commit]' + commit_user_name: Pulumi Bot + commit_user_email: pulumi-bot@users.noreply.github.com diff --git a/.github/workflows/workflow_dotnet_application.yml b/.github/workflows/workflow_dotnet_application.yml index 3647a78f..e2868c14 100644 --- a/.github/workflows/workflow_dotnet_application.yml +++ b/.github/workflows/workflow_dotnet_application.yml @@ -29,6 +29,8 @@ jobs: working-directory: .github/test-stacks/dotnet env: PULUMI_CONFIG_PASSPHRASE: not-a-secret + - run: yarn install + - run: yarn build - uses: ./ env: PULUMI_CONFIG_PASSPHRASE: not-a-secret diff --git a/.github/workflows/workflow_go_application.yml b/.github/workflows/workflow_go_application.yml index 7f36cfa8..b9d23026 100644 --- a/.github/workflows/workflow_go_application.yml +++ b/.github/workflows/workflow_go_application.yml @@ -29,6 +29,8 @@ jobs: working-directory: .github/test-stacks/golang env: PULUMI_CONFIG_PASSPHRASE: not-a-secret + - run: yarn install + - run: yarn build - uses: ./ env: PULUMI_CONFIG_PASSPHRASE: not-a-secret diff --git a/.github/workflows/workflow_nodejs_application.yml b/.github/workflows/workflow_nodejs_application.yml index a3031adc..8781d913 100644 --- a/.github/workflows/workflow_nodejs_application.yml +++ b/.github/workflows/workflow_nodejs_application.yml @@ -31,6 +31,8 @@ jobs: PULUMI_CONFIG_PASSPHRASE: not-a-secret - run: npm install working-directory: .github/test-stacks/nodejs + - run: yarn install + - run: yarn build - uses: ./ env: PULUMI_CONFIG_PASSPHRASE: not-a-secret diff --git a/.github/workflows/workflow_python_application.yml b/.github/workflows/workflow_python_application.yml index 37f179d7..a402cb5d 100644 --- a/.github/workflows/workflow_python_application.yml +++ b/.github/workflows/workflow_python_application.yml @@ -31,6 +31,8 @@ jobs: PULUMI_CONFIG_PASSPHRASE: not-a-secret - run: pip install -r requirements.txt working-directory: .github/test-stacks/python + - run: yarn install + - run: yarn build - uses: ./ env: PULUMI_CONFIG_PASSPHRASE: not-a-secret diff --git a/package.json b/package.json index 275079bb..329a3fa2 100644 --- a/package.json +++ b/package.json @@ -20,11 +20,6 @@ "{.eslintrc}": "prettier --write", "*.md": "prettier --write" }, - "husky": { - "hooks": { - "pre-commit": "yarn build && git add dist/* && lint-staged" - } - }, "devDependencies": { "@types/faker": "^5.1.7", "@types/jest": "~26.0.20",