From fa4d432badbfb7704abc93466847f39994c69f83 Mon Sep 17 00:00:00 2001 From: Muhammad Ilham Date: Sat, 11 Feb 2023 23:02:10 +0700 Subject: [PATCH] fix(deployment workflow): fix jobs Signed-off-by: Muhammad Ilham --- .github/workflows/deployment.yaml | 52 +++++++++++-------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index 3335166..6f05a83 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -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 @@ -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: