From cd77dfb24fa743a6a18f4f06a12415cc1e8e9f2c Mon Sep 17 00:00:00 2001 From: Rajat Jindal Date: Sat, 22 Mar 2025 12:36:47 +0530 Subject: [PATCH 1/2] deploy preview on PR for testing e2e Signed-off-by: Rajat Jindal --- .github/workflows/preview.yml | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/preview.yml diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 0000000..ae90f57 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,42 @@ +name: Preview deploy to Fermyon Cloud +on: + pull_request: + branches: ["main"] + types: ["opened", "synchronize", "reopened", "closed"] + +jobs: + deploy: + runs-on: ubuntu-latest + ## run only from my branch + if: github.event.pull_request.head.repo.fork == false && github.repository_owner == 'rajatjindal' + steps: + - name: Checkout code repo + uses: actions/checkout@v3 + + - name: setup spin + uses: fermyon/actions/spin/setup@v1 + + - name: setup cloud plugin + run: spin plugin install cloud --yes + + - name: "Install Go" + uses: actions/setup-go@v3 + with: + go-version: "1.21" + + - name: "Install TinyGo" + uses: rajatjindal/setup-actions/tinygo@v0.0.1 + with: + version: 'v0.30.0' + + - name: Deploy a staging version + uses: fermyon/actions/spin/preview@v1 + with: + fermyon_token: ${{ secrets.FERMYON_CLOUD_TOKEN }} + undeploy: ${{ github.event.pull_request && github.event.action == 'closed' }} + github_token: ${{ secrets.GITHUB_TOKEN }} + variables: |- + gh_token=${{ secrets.GH_TOKEN }} + upstream_spin_plugins_index_repo_name=spin-plugins-test-upstream + upstream_spin_plugins_index_repo_owner=rajatjindal + \ No newline at end of file From f3695d08fc89ca827349581e23e070a50927e1e4 Mon Sep 17 00:00:00 2001 From: Rajat Jindal Date: Sat, 22 Mar 2025 13:20:00 +0530 Subject: [PATCH 2/2] give permissions to comment Signed-off-by: Rajat Jindal --- .github/workflows/preview.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index ae90f57..aaa08da 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -3,7 +3,8 @@ on: pull_request: branches: ["main"] types: ["opened", "synchronize", "reopened", "closed"] - +permissions: + pull-requests: write jobs: deploy: runs-on: ubuntu-latest @@ -39,4 +40,3 @@ jobs: gh_token=${{ secrets.GH_TOKEN }} upstream_spin_plugins_index_repo_name=spin-plugins-test-upstream upstream_spin_plugins_index_repo_owner=rajatjindal - \ No newline at end of file