From ec9cb5fa8065b01d13c698b3890539d018a80ac9 Mon Sep 17 00:00:00 2001 From: James Ma Date: Wed, 4 Dec 2024 10:48:33 -0800 Subject: [PATCH 1/3] Update README.md (#207) * Update README.md * Update README.md fixed typo --------- Co-authored-by: Andras Kerekes --- README.md | 95 +++---------------------------------------------------- 1 file changed, 4 insertions(+), 91 deletions(-) diff --git a/README.md b/README.md index 9da692d4..6c8c1a89 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ The Functions Framework lets you write lightweight functions that run in many different environments, including: * Your local development machine -* [Cloud Run and Cloud Run on GKE](https://cloud.google.com/run/) * [Knative](https://github.com/knative/)-based environments The framework allows you to go from: @@ -110,102 +109,16 @@ curl localhost:8080 # Output: Hello World from a PHP HTTP function! ``` -## Run your function on Google Cloud Functions +## Run your function on Google Cloud Run Functions **NOTE**: For an extensive list of samples, see the [PHP functions samples][functions-samples] and the [official how-to guides][functions-how-to]. -Follow the steps below to deploy to Google Cloud Functions. More information -on function deployment is available in the -[GCF documentation](https://cloud.google.com/functions/docs/deploying). +Follow the [Cloud Run function quickstart](https://cloud.google.com/run/docs/quickstarts/functions/deploy-functions-gcloud#php) for PHP to learn how to deploy a function to Cloud Run. -To run your function on Cloud Functions, first you must have the [gcloud SDK][gcloud] installed and [authenticated][gcloud-auth]. +## Run your function as a container in Cloud Run -Make sure your source file (which defines your function) is called -`index.php`. The Functions Framework lets you choose a function source file, -but Cloud Functions currently uses the default of `index.php`. - -Decide _which_ function in the source file to invoke, that is, the name that you -used when writing the function. This is called the **target**. - -Choose a Cloud Functions **name** for your function. The **name** identifies -this function deployment (e.g. in the cloud console) and is also part of the -function's default URL. (Note: the **name** and the **target** do not have to -be the same value.) - -Then, from the directory containing your function source, issue the gcloud command to deploy: - -```sh -gcloud functions deploy $YOUR_FUNCTION_NAME \ - --runtime=php74 \ - --entry-point=$YOUR_FUNCTION_TARGET \ - --trigger-http -``` - -The `--entry-point` flag can be omitted if the **target** has the same value -as the **name**. - -If your function handles events rather than HTTP requests, you'll need to -replace `--trigger-http` with a different trigger. For details, see the -[reference documentation](https://cloud.google.com/sdk/gcloud/reference/functions/deploy) -for `gcloud functions deploy`. - -To update your deployment, just redeploy using the same function **name**. -Configuration flags are not required. - -## Run your function in Cloud Run - -To run your function in Cloud Run, first you must have the [gcloud SDK][gcloud] installed and [authenticated][gcloud-auth]. - -Additionally, you need to have a Google Cloud project ID for the -[Google Cloud Project][gcp-project] you want to use. - -After completing the steps under **Installation** and **Define your Function**, build the container using the example `Dockerfile`. This Dockerfile is -built on top of the [App Engine runtime for PHP 7.4][gae-php7], but you can use -any container you want as long as your application listens on **Port 8080**. - -```sh -docker build . \ - -f vendor/google/cloud-functions-framework/examples/hello/Dockerfile \ - -t gcr.io/$GCLOUD_PROJECT/my-cloud-function -``` - -> **NOTE**: Be sure to replace `$GCLOUD_PROJECT` with your Google Cloud project -ID, or set the environment variable using `export GCLOUD_PROJECT="some-project-id"`. - -Next, push your image to [Google Container Registry](https://cloud.google.com/container-registry). This will allow you to deploy it directly from Cloud Run. - -```sh -docker push gcr.io/$GCLOUD_PROJECT/my-cloud-function -``` - -Finally, use the `gcloud` command-line tool to deploy to Cloud Run: - -```sh -gcloud run deploy my-cloud-function \ - --image=gcr.io/$GCLOUD_PROJECT/my-cloud-function \ - --platform managed \ - --set-env-vars "FUNCTION_TARGET=helloHttp" \ - --allow-unauthenticated \ - --region $CLOUD_RUN_REGION \ - --project $GCLOUD_PROJECT -``` - -> **NOTE**: Be sure to replace `$CLOUD_RUN_REGION` with the -[correct region][cloud-run-regions] for your Cloud Run instance, for example -`us-central1`. - -After your instance deploys, you can access it at the URL provided, or view it -in the [Cloud Console][cloud-run-console]. - -[functions-samples]: https://github.com/GoogleCloudPlatform/php-docs-samples/tree/main/functions -[functions-how-to]: https://cloud.google.com/functions/docs/how-to -[gcloud]: https://cloud.google.com/sdk/gcloud/ -[gcloud-auth]: https://cloud.google.com/sdk/docs/authorizing -[gcp-project]: https://cloud.google.com/resource-manager/docs/creating-managing-projects -[gae-php7]: https://cloud.google.com/appengine/docs/standard/php7/runtime -[cloud-run-regions]: https://cloud.google.com/run/docs/locations -[cloud-run-console]: https://console.cloud.google.com/run +You can manually build your function as a container and deploy it into Cloud Run. Follow the [Cloud Run instructions for building a function](https://cloud.google.com/run/docs/building/functions) for complete instructions. ## Use CloudEvents From f79172d71f498bbffc4ff86a6cee6186dc69a9f4 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Tue, 31 Dec 2024 00:43:00 +0100 Subject: [PATCH 2/3] chore(deps): update all non-major dependencies (#206) Co-authored-by: Andras Kerekes --- .github/workflows/conformance.yml | 2 +- .github/workflows/dependency-review.yml | 4 ++-- .github/workflows/lint.yaml | 2 +- .github/workflows/scorecard.yml | 4 ++-- .github/workflows/unit.yml | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml index d2df4eab..e52a35c4 100644 --- a/.github/workflows/conformance.yml +++ b/.github/workflows/conformance.yml @@ -18,7 +18,7 @@ jobs: name: PHP ${{ matrix.php-version }} Conformance Test steps: - name: Harden Runner - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: egress-policy: block allowed-endpoints: > diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 2601fc89..e3d6a018 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Harden Runner - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: disable-sudo: true egress-policy: block @@ -28,4 +28,4 @@ jobs: - name: 'Checkout Repository' uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: 'Dependency Review' - uses: actions/dependency-review-action@a6993e2c61fd5dc440b409aa1d6904921c5e1894 # v4.3.5 + uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 80e3ae03..f3fcacef 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Harden Runner - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: disable-sudo: true egress-policy: block diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index da70a7f6..dc15a2b1 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -25,7 +25,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: disable-sudo: true egress-policy: block @@ -59,6 +59,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 + uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6 with: sarif_file: results.sarif diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 9b570ba9..8d8e6e78 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -17,7 +17,7 @@ jobs: name: PHP ${{ matrix.php-versions }} Unit Test steps: - name: Harden Runner - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: egress-policy: block allowed-endpoints: > From 99880eeaa546c5b4ace83f288c5100003456bd61 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Tue, 31 Dec 2024 00:47:59 +0100 Subject: [PATCH 3/3] chore(deps): update oskarstark/php-cs-fixer-ga:latest docker digest to b9b4d3b (#205) Co-authored-by: Andras Kerekes --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index f3fcacef..18b4d00d 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -21,6 +21,6 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: PHP-CS-Fixer - uses: docker://oskarstark/php-cs-fixer-ga:latest@sha256:0c86f441e2141a32bfb54deebb9d25ae6dd54dbca64d95f9eec0c92b0c3dcad1 + uses: docker://oskarstark/php-cs-fixer-ga:latest@sha256:b9b4d3b392a37371332a452d0ff2891bf4971b57ddb2b52b8a7fac31d87f4dae with: args: . --diff --dry-run