[feat] json feed loader #650
Workflow file for this run
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: Code Test | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '**/*.md' | |
- '.vscode/**' | |
- '.husky/**' | |
pull_request: | |
paths-ignore: | |
- '**/*.md' | |
- '.vscode/**' | |
- '.husky/**' | |
jobs: | |
test: | |
permissions: | |
contents: read | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
- name: Install tools from asdf config | |
uses: ai/asdf-cache-action@v1 | |
- name: Install dependencies | |
run: pnpm install --ignore-scripts | |
- name: Run tests | |
run: pnpm run -r --include-workspace-root '/^test:(?!markdown\b)/' | |
env: | |
FORCE_COLOR: 1 | |
STAGING: 1 | |
- name: Upload web assets | |
if: github.ref == 'refs/heads/main' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: web-client-assets-${{ github.sha }} | |
path: | | |
web/dist/ | |
web/routes.regexp | |
retention-days: 1 | |
staging: | |
needs: test | |
if: github.ref == 'refs/heads/main' | |
permissions: | |
contents: read | |
id-token: write | |
name: Staging Deploy | |
runs-on: ubuntu-latest | |
env: | |
PROJECT_ID: slowreader-418220 | |
REGION: europe-west1 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download web assets from test step | |
uses: actions/download-artifact@v4 | |
with: | |
name: web-client-assets-${{ github.sha }} | |
path: web/ | |
- name: Auth Google Cloud | |
uses: google-github-actions/auth@v2 | |
with: | |
workload_identity_provider: projects/225773869708/locations/global/workloadIdentityPools/github/providers/slowreader | |
service_account: github-deploy@${{ env.PROJECT_ID }}.iam.gserviceaccount.com | |
- name: Install Google Cloud | |
uses: google-github-actions/setup-gcloud@v2 | |
- name: Auth Docker | |
run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet | |
- name: Build Docker image | |
run: docker build -t ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/staging/staging:latest ./web | |
- name: Push Docker image | |
run: docker push ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/staging/staging:latest | |
- name: Deploy to Cloud Run | |
run: | | |
gcloud run deploy staging \ | |
--project ${{ env.PROJECT_ID }} \ | |
--image ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/staging/staging:latest \ | |
--region ${{ env.REGION }} \ | |
--allow-unauthenticated \ | |
--service-account github-deploy@${{ env.PROJECT_ID }}.iam.gserviceaccount.com | |
- name: Move traffic to new revision | |
run: | | |
gcloud run services update-traffic staging \ | |
--project ${{ env.PROJECT_ID }} \ | |
--region ${{ env.REGION }} \ | |
--to-latest | |
- name: Delete previous images | |
run: | | |
untagged=$(gcloud artifacts docker images list $REGION-docker.pkg.dev/$PROJECT_ID/staging/staging --include-tags --format="get(version)" --filter="tags = ''") | |
for digest in $untagged; do | |
image=$REGION-docker.pkg.dev/$PROJECT_ID/staging/staging@$digest | |
echo "Deleting unused image: $image" | |
gcloud artifacts docker images delete $image --quiet | |
done |