Skip to content

Commit

Permalink
Merge pull request #2 from gmmcal/make-more-reusable
Browse files Browse the repository at this point in the history
NEW: Make workflows more reusable to be used with gmmcal.com.br and ynab projects
  • Loading branch information
gmmcal authored May 20, 2024
2 parents 175c453 + 0adb76b commit d77981a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/_cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ name: End-to-end Tests
on:
workflow_call:
inputs:
image:
type: string
required: true
application-image:
type: string
required: true
pattern:
type: string
required: true
Expand All @@ -15,7 +21,7 @@ jobs:
name: "End-to-end - ${{ inputs.name }} (${{ matrix.browser }})"
runs-on: ubuntu-20.04
container:
image: gmmcal/gmmcal:cypress
image: ${{ inputs.image }}
env:
CYPRESS_BASE_URL: http://web:3000
CYPRESS_SPEC_PATTERN: ${{ inputs.pattern }}
Expand All @@ -36,7 +42,7 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

web:
image: gmmcal/gmmcal:test
image: ${{ inputs.application-image }}
env:
DATABASE_URL: postgres://postgres:postgres@postgres:5432/gmmcalcombr_test
ON_CYPRESS: true
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ on:
name:
type: string
required: true
tag-name:
image:
type: string
required: false
default: "gmmcal/gmmcal:test"
required: true
target:
type: string
required: false
Expand Down Expand Up @@ -48,6 +47,6 @@ jobs:
push: ${{ inputs.publish }}
context: .
target: ${{ inputs.target }}
tags: ${{ inputs.tag-name }}
cache-from: type=registry,ref=gmmcal/gmmcal:buildcache${{ inputs.target }}
cache-to: type=registry,ref=gmmcal/gmmcal:buildcache${{ inputs.target }},mode=max
tags: ${{ inputs.image }}
cache-from: type=registry,ref=gmmcal/${{ github.event.repository.name }}:${{ inputs.target }}cache
cache-to: type=registry,ref=gmmcal/${{ github.event.repository.name }}:${{ inputs.target }}cache,mode=max
7 changes: 3 additions & 4 deletions .github/workflows/_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ name: Lint
on:
workflow_call:
inputs:
image:
type: string
required: true
name:
type: string
required: true
command:
type: string
required: true
image:
type: string
required: false
default: gmmcal/gmmcal:test

jobs:
lint:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy preview image
on:
workflow_call:
inputs:
tag-name:
image:
type: string
required: true

Expand All @@ -18,5 +18,5 @@ jobs:
- name: Create Render service preview
id: result
run: |
curl -X POST https://api.render.com/v1/services/srv-${{ secrets.DEPLOY_SERVICE }}/preview -H 'Authorization: Bearer ${{ secrets.RENDER_API_KEY }}' -H 'Accept: application/json' -d '{"imagePath": "docker.io/${{ inputs.tag-name }}", "name": "gustavocunha-preview-pr-${{ github.event.number }}-${{ github.run_number }}"}' > result.json
curl -X POST https://api.render.com/v1/services/srv-${{ secrets.DEPLOY_SERVICE }}/preview -H 'Authorization: Bearer ${{ secrets.RENDER_API_KEY }}' -H 'Accept: application/json' -d '{"imagePath": "docker.io/${{ inputs.image }}", "name": "gustavocunha-preview-pr-${{ github.event.number }}-${{ github.run_number }}"}' > result.json
echo "url=$(jq -r '.service.serviceDetails.url' result.json)" >> "$GITHUB_OUTPUT"
5 changes: 4 additions & 1 deletion .github/workflows/_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Backend Tests
on:
workflow_call:
inputs:
image:
type: string
required: true
command:
type: string
required: true
Expand All @@ -12,7 +15,7 @@ jobs:
name: Backend
runs-on: ubuntu-20.04
container:
image: gmmcal/gmmcal:test
image: ${{ inputs.image }}
env:
DATABASE_URL: postgres://postgres:postgres@postgres:5432/gmmcalcombr_test
DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL: true
Expand Down

0 comments on commit d77981a

Please sign in to comment.