Upload secrets and deploy to Vercel #228
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Upload secrets and deploy to Vercel | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} | |
AVALANCHE_FUJI_RPC_URL: ${{ secrets.AVALANCHE_FUJI_RPC_URL }} | |
X_BEARER_TOKEN: ${{ secrets.X_BEARER_TOKEN }} | |
on: | |
schedule: | |
- cron: "00 00 * * */2" | |
jobs: | |
change-environment-variable: | |
name: Upload secrets and deploy to Vercel | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Upload secrets and get version number | |
id: get-version | |
working-directory: ./app | |
run: | | |
X_SECRET_VERSION_ID=$(bash ../.github/workflows/deploy.sh | bash ../.github/workflows/get-version-number.sh) | |
echo "X_SECRET_VERSION_ID=$X_SECRET_VERSION_ID" >> "$GITHUB_OUTPUT" | |
- name: Remove old environment variables | |
run: | | |
if vercel env ls --token=${{ secrets.VERCEL_API_TOKEN }} | grep -q X_SECRET_VERSION_ID; then | |
echo "Environment variable X_SECRET_VERSION_ID exists. Removing..." | |
vercel env rm X_SECRET_VERSION_ID preview --token=${{ secrets.VERCEL_API_TOKEN }} --yes | |
vercel env rm X_SECRET_VERSION_ID production --token=${{ secrets.VERCEL_API_TOKEN }} --yes | |
vercel env rm X_SECRET_VERSION_ID development --token=${{ secrets.VERCEL_API_TOKEN }} --yes | |
else | |
echo "Environment variable X_SECRET_VERSION_ID does not exist." | |
fi | |
- name: Upload new environment variables | |
run: | | |
echo "${{ steps.get-version.outputs.X_SECRET_VERSION_ID }}" | vercel env add X_SECRET_VERSION_ID preview --token=${{ secrets.VERCEL_API_TOKEN }} --yes | |
echo "${{ steps.get-version.outputs.X_SECRET_VERSION_ID }}" | vercel env add X_SECRET_VERSION_ID development --token=${{ secrets.VERCEL_API_TOKEN }} --yes | |
echo "${{ steps.get-version.outputs.X_SECRET_VERSION_ID }}" | vercel env add X_SECRET_VERSION_ID production --token=${{ secrets.VERCEL_API_TOKEN }} --yes | |
- name: Pull Vercel Environment Information | |
run: vercel pull --yes --token=${{ secrets.VERCEL_API_TOKEN }} | |
- name: Build Project Artifacts | |
run: | | |
vercel build --prod --token=${{ secrets.VERCEL_API_TOKEN }} | |
- name: Deploy Project Artifacts to Vercel | |
run: vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_API_TOKEN }} |