-
Notifications
You must be signed in to change notification settings - Fork 1
feat(ci): implement deployment workflow for tagged versions #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| name: Deploy to wildcat-docker (Cloudflare Pages) | ||
|
|
||
| on: | ||
| # deploy new tag to CF project PREVIEW | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
|
|
||
| # promote a version to CF project PRODUCTION | ||
| workflow_dispatch: | ||
| inputs: | ||
| environment: | ||
| description: 'target' | ||
| required: true | ||
| default: 'wildcat-dev-docker' | ||
| type: choice | ||
| options: | ||
| - wildcat-docker | ||
| - wildcat-dev-docker | ||
|
|
||
| jobs: | ||
| deploy: | ||
|
|
||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| deployments: write | ||
|
|
||
| # define environments | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - environment: 'wildcat-dev-docker' | ||
| project_name: ${{ secrets.CLOUDFLARE_PROJECT_DEV_DOCKER }} | ||
| vite_api_base_url: ${{ vars.VITE_API_BASE_URL_DEV_DOCKER }} | ||
| vite_keycloak_url: ${{ vars.VITE_KEYCLOAK_URL_DEV_DOCKER }} | ||
| vite_keycloak_realm: 'dev' | ||
| vite_keycloak_client_id: 'bff-dashboard' | ||
| - environment: 'wildcat-docker' | ||
| project_name: ${{ secrets.CLOUDFLARE_PROJECT_DOCKER }} | ||
| vite_api_base_url: ${{ vars.VITE_API_BASE_URL_DOCKER }} | ||
| vite_keycloak_url: ${{ vars.VITE_KEYCLOAK_URL_DOCKER }} | ||
| vite_keycloak_realm: 'dev' | ||
| vite_keycloak_client_id: 'bff-dashboard' | ||
|
|
||
| # only run job for the selected environment on manual dispatch or on push to a tag | ||
| if: | | ||
| github.event_name == 'push' || | ||
| (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == matrix.environment) | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.ref }} | ||
| fetch-depth: 0 | ||
|
|
||
| # only allow tags on manual dispatch | ||
| - name: Validate Tag on Manual Dispatch | ||
| if: github.event_name == 'workflow_dispatch' | ||
| run: | | ||
| if [[ "${{ github.ref_type }}" != 'tag' ]]; then | ||
| echo "::error::Manual deployments must be triggered from a tag." | ||
| echo "::error::Please select a tag from the 'Use workflow from' dropdown, not a branch." | ||
| exit 1 | ||
| fi | ||
| echo "✅ Validation successful: Running from tag '${{ github.ref_name }}'." | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Build application for ${{ matrix.environment }} | ||
| run: npm run build | ||
| env: | ||
| VITE_API_BASE_URL: ${{ matrix.vite_api_base_url }} | ||
| VITE_KEYCLOAK_URL: ${{ matrix.vite_keycloak_url }} | ||
| VITE_KEYCLOAK_REALM: ${{ matrix.vite_keycloak_realm }} | ||
| VITE_KEYCLOAK_CLIENT_ID: ${{ matrix.vite_keycloak_client_id }} | ||
| VITE_API_MOCKING_ENABLED: false | ||
|
|
||
| - name: Deploy ${{ matrix.environment }} to Cloudflare Pages (PREVIEW) | ||
| id: deploy_preview | ||
| if: github.event_name == 'push' | ||
| uses: cloudflare/wrangler-action@v3 | ||
| with: | ||
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
| command: pages deploy dist --project-name=${{ matrix.project_name }} --branch=preview | ||
|
|
||
| - name: Deploy ${{ matrix.environment }} to Cloudflare Pages (PRODUCTION) | ||
| id: deploy_production | ||
| if: github.event_name == 'workflow_dispatch' | ||
| uses: cloudflare/wrangler-action@v3 | ||
Check warningCode scanning / CodeQL Unpinned tag for a non-immutable Action in workflow Medium
Unpinned 3rd party Action 'Deploy to wildcat-docker (Cloudflare Pages)' step
Uses Step: deploy_production Error loading related location Loading |
||
| with: | ||
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
| # Target the production branch ('main' or 'master') for manual deployments | ||
| command: pages deploy dist --project-name=${{ matrix.project_name }} --branch=master | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Unpinned tag for a non-immutable Action in workflow Medium