Skip to content

Commit

Permalink
fix(deployment workflow): fix jobs
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Ilham <muhd.iiilham@gmail.com>
  • Loading branch information
mhdiiilham committed Feb 11, 2023
1 parent 49c24aa commit fa4d432
Showing 1 changed file with 19 additions and 33 deletions.
52 changes: 19 additions & 33 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,28 @@ jobs:

- name: Run Unit Test
run: go test -race -cover -v ./...

migration:
name: Run Pending Migration
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

secret:
- name: Install golang-migrate
run: go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest

- name: Run Pending Migration(s)
run: migrate -database ${{ secrets.POSTGRESQL_URL }} -path migrations ${{ github.event.inputs.migrate }} up

deployment:
name: Deployment
runs-on: ubuntu-latest
name: Create Secret app.env File
environment: ${{ github.event.inputs.environment }}
outputs:
envfile: ${{ steps.stepCreate.outputs.value }}
needs: [init, migration]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -48,35 +63,6 @@ jobs:
file_name: app.env
fail_on_empty: false

- name: Save result to output
id: stepCreate
run: cat app.env >> $GITHUB_OUTPUT

deployment:
name: Deployment
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
needs: [init, secret]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get Secret Values
run: |
echo ${{ needs.secret.outputs.envfile }} >> app.env
cat $(cat app.env)
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Install golang-migrate
run: go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest

- name: Run Migrations
run: migrate -database ${{ secrets.POSTGRESQL_URL }} -path migrations ${{ github.event.inputs.migrate }} up

- name: Setup Cloud cli
uses: google-github-actions/setup-gcloud@v0.2.0
with:
Expand Down

0 comments on commit fa4d432

Please sign in to comment.