Skip to content

Commit

Permalink
ci: trigger action on feature's main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Th1nkK1D committed Aug 26, 2024
1 parent 0b73872 commit 4c179dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: staging.yml
workflow_conclusion: success
name: build-artifact
name: build-main
- name: Upload to server
uses: burnett01/[email protected]
with:
Expand Down
21 changes: 17 additions & 4 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build and deploy to staging
on:
push:
branches: ['main']
branches: ['main', '**/main']
paths-ignore:
- '**/README.md'
- '.github/workflows/production.yml'
Expand All @@ -10,6 +10,12 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set artifact name
run: |
ARTIFACT=${{ github.ref_name }}
ARTIFACT=build-${ARTIFACT/\//-}
echo "ARTIFACT=${ARTIFACT}" >> $GITHUB_ENV
echo "Set artifact name as ${ARTIFACT}"
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
Expand All @@ -27,24 +33,31 @@ jobs:
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact
name: ${{ env.ARTIFACT }}
path: build/*
if-no-files-found: error
retention-days: 7
retention-days: ${{ github.ref_name == 'main' && 7 || 1 }}
overwrite: true
deploy-to-staging:
runs-on: ubuntu-latest
needs: build
steps:
- name: Set artifact name
run: |
ARTIFACT=${{ github.ref_name }}
ARTIFACT=build-${ARTIFACT/\//-}
echo "ARTIFACT=${ARTIFACT}" >> $GITHUB_ENV
echo "Set artifact name as ${ARTIFACT}"
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-artifact
name: ${{ env.ARTIFACT }}
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: parliament-watch
directory: ./
branch: ${{ github.ref_name }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 4c179dc

Please sign in to comment.