diff --git a/.github/workflows/pr-deploy.yml b/.github/workflows/pr-deploy.yml new file mode 100644 index 00000000..325f2508 --- /dev/null +++ b/.github/workflows/pr-deploy.yml @@ -0,0 +1,20 @@ +name: PR Deployment + +on: [pull_request, workflow_dispatch] + +jobs: + deploy: + permissions: + contents: read + pull-requests: write + + uses: ./.github/workflows/reusable-deploy-vercel.yml + + with: + PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} + COMMIT_SHA: ${{ github.event.pull_request.head.sha }} + + secrets: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/prod-deploy.yml b/.github/workflows/prod-deploy.yml new file mode 100644 index 00000000..8a7bd0a2 --- /dev/null +++ b/.github/workflows/prod-deploy.yml @@ -0,0 +1,22 @@ +name: PROD Deployment + +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + deploy: + permissions: + contents: read + + uses: ./.github/workflows/reusable-deploy-vercel.yml + + with: + PROD: true + + secrets: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/reusable-deploy-vercel.yml b/.github/workflows/reusable-deploy-vercel.yml new file mode 100644 index 00000000..8fabf31f --- /dev/null +++ b/.github/workflows/reusable-deploy-vercel.yml @@ -0,0 +1,65 @@ +name: Vercel Deployment (reusable) + +on: + workflow_call: + inputs: + COMMIT_SHA: + required: false + type: string + PULL_REQUEST_NUMBER: + required: false + type: number + PROD: + required: false + type: boolean + default: false + secrets: + VERCEL_ORG_ID: + required: true + VERCEL_PROJECT_ID: + required: true + VERCEL_TOKEN: + required: true + +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_ENVIRONMENT: ${{ inputs.PROD == true && 'production' || 'preview' }} + VERCEL_CLI_ENV_FLAG: ${{ inputs.PROD == true && '--prod' || '' }} + +jobs: + deploy: + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install pnpm + run: npm install -g pnpm + + - name: Install Vercel CLI + run: npm install --global vercel@latest + + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=${{ env.VERCEL_ENVIRONMENT }} --token=${{ secrets.VERCEL_TOKEN }} + + - name: Build Project Artifacts + run: vercel build ${{ env.VERCEL_CLI_ENV_FLAG }} --token=${{ secrets.VERCEL_TOKEN }} + + - name: Deploy Project Artifacts to Vercel + run: vercel deploy ${{ env.VERCEL_CLI_ENV_FLAG }} --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > /tmp/vercel-deployment-url.txt + + - name: Generate PR comment + if: ${{ inputs.PULL_REQUEST_NUMBER != 0 }} + uses: actions/github-script@v7 + with: + script: | + const fsAsync = require("fs").promises; + const deploymentUrl = await fsAsync.readFile("/tmp/vercel-deployment-url.txt", "utf8"); + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: ${{ inputs.PULL_REQUEST_NUMBER }}, + body: `Version ${{ inputs.COMMIT_SHA }} deployed to Vercel: ${deploymentUrl}` + }); diff --git a/README.md b/README.md index 3b72cfc1..da869b2e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ --- ## 📖 **Introduction** - +123 Welcome to a centralized repository of links and resources dedicated to Israel. Utilizing the collaborative power of Git, our goal is to galvanize support for Israel, especially during challenging moments. ---