mirror of
https://codeberg.org/JasterV/spazio-solazzo.git
synced 2026-04-26 18:20:03 +00:00
feat: optimize CI by using cache (#7)
This commit is contained in:
parent
c3ddf11bd8
commit
e3b3959ef9
2 changed files with 47 additions and 9 deletions
22
.github/workflows/production.yml
vendored
22
.github/workflows/production.yml
vendored
|
|
@ -18,15 +18,31 @@ jobs:
|
||||||
name: Deploy app
|
name: Deploy app
|
||||||
needs: ci
|
needs: ci
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
concurrency: deploy-group # optional: ensure only one action runs at a time
|
concurrency: deploy-group
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
name: production
|
name: production
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
- uses: superfly/flyctl-actions/setup-flyctl@master
|
- uses: superfly/flyctl-actions/setup-flyctl@master
|
||||||
|
|
||||||
|
- name: Authenticate with Fly registry
|
||||||
|
run: flyctl auth docker
|
||||||
|
|
||||||
|
- name: Build and push Docker image (GHA cache)
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
context: .
|
||||||
|
tags: registry.fly.io/${{ github.repository }}:sha-${{ github.sha }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
- name: Set Fly secrets
|
- name: Set Fly secrets
|
||||||
run: |
|
run: |
|
||||||
flyctl secrets --access-token "$FLY_API_TOKEN" set \
|
flyctl secrets --access-token "$FLY_API_TOKEN" set \
|
||||||
|
|
@ -44,4 +60,4 @@ jobs:
|
||||||
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
|
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
|
||||||
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
||||||
|
|
||||||
- run: flyctl deploy --remote-only
|
- run: flyctl deploy --image ${{ env.IMAGE_TAG }}
|
||||||
|
|
|
||||||
34
.github/workflows/review.yml
vendored
34
.github/workflows/review.yml
vendored
|
|
@ -12,43 +12,51 @@ env:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
|
if: github.event.action != 'closed'
|
||||||
uses: ./.github/workflows/ci.yml
|
uses: ./.github/workflows/ci.yml
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
review_app:
|
build_and_deploy:
|
||||||
|
if: github.event.action != 'closed'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: ci
|
needs: ci
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
url: ${{ steps.deploy.outputs.url }}
|
url: ${{ steps.deploy.outputs.url }}
|
||||||
# Only run one deployment at a time per PR.
|
# Only run one deployment at a time per PR.
|
||||||
concurrency:
|
concurrency:
|
||||||
group: pr-${{ github.event.number }}
|
group: pr-${{ github.event.number }}
|
||||||
|
|
||||||
# Deploying apps with this "review" environment allows the URL for the app to be displayed in the PR UI.
|
|
||||||
# Feel free to change the name of this environment.
|
|
||||||
environment:
|
environment:
|
||||||
name: review
|
name: review
|
||||||
# The script in the `deploy` sets the URL output for each review app.
|
|
||||||
url: ${{ steps.deploy.outputs.url }}
|
url: ${{ steps.deploy.outputs.url }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Get code
|
- name: Get code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
- name: Install flyctl CLI
|
- name: Install flyctl CLI
|
||||||
uses: superfly/flyctl-actions/setup-flyctl@master
|
uses: superfly/flyctl-actions/setup-flyctl@master
|
||||||
|
|
||||||
- name: Authenticate with Fly.io registry
|
- name: Authenticate with Fly.io registry
|
||||||
run: flyctl auth docker
|
run: flyctl auth docker
|
||||||
|
|
||||||
- name: Create Fly App before pushing docker image to registry
|
- name: Create Fly App before pushing docker image to registry
|
||||||
run: |
|
run: |
|
||||||
flyctl apps create ${{ env.APP_NAME }} --org ${{ env.FLY_ORG }} || true
|
flyctl apps create ${{ env.APP_NAME }} --org ${{ env.FLY_ORG }} || true
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
tags: registry.fly.io/${{ env.APP_NAME }}:1.19
|
tags: registry.fly.io/${{ env.APP_NAME }}:sha-${{ github.sha }}
|
||||||
context: .
|
context: .
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
- name: Deploy PR app to Fly.io
|
- name: Deploy PR app to Fly.io
|
||||||
id: deploy
|
id: deploy
|
||||||
uses: superfly/fly-pr-review-apps@1.5.0
|
uses: superfly/fly-pr-review-apps@1.5.0
|
||||||
|
|
@ -64,3 +72,17 @@ jobs:
|
||||||
DATABASE_URL=${{ secrets.DATABASE_URL }}
|
DATABASE_URL=${{ secrets.DATABASE_URL }}
|
||||||
SECRET_KEY_BASE=${{ secrets.SECRET_KEY_BASE }}
|
SECRET_KEY_BASE=${{ secrets.SECRET_KEY_BASE }}
|
||||||
PHX_HOST=${{ env.APP_NAME }}.fly.dev
|
PHX_HOST=${{ env.APP_NAME }}.fly.dev
|
||||||
|
|
||||||
|
review_app_cleanup:
|
||||||
|
if: github.event.action == 'closed'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: pr-${{ github.event.number }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Destroy PR app
|
||||||
|
uses: superfly/fly-pr-review-apps@1.5.0
|
||||||
|
with:
|
||||||
|
name: ${{ env.APP_NAME }}
|
||||||
|
config: fly.review.toml
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue