Skip to content

Update condition for Deploy-production in CI/CD workflow file #10

Update condition for Deploy-production in CI/CD workflow file

Update condition for Deploy-production in CI/CD workflow file #10

Workflow file for this run

name: gol2
on:
push:
branches:
- 'dev'
workflow_dispatch:
jobs:
Build:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.meta.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: registry.digitalocean.com/governance/gol2
flavor: latest=false
tags: |
type=ref,suffix=-{{sha}},event=branch
type=ref,suffix=-{{sha}},event=pr
- name: Login to DO Container Registry
uses: docker/login-action@v2
with:
registry: registry.digitalocean.com
username: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
password: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
secrets: |
"certificate=${{ secrets.CERTIFICATE }}"
Deploy-review:
if: github.event_name == 'workflow_dispatch'
needs: Build
runs-on: ubuntu-latest
env:
tag: ${{ needs.Build.outputs.tag }}
environment:
name: review
url: https://api-review.yuki-labs.dev
steps:
- name: DigitalOcean App Platform deployment
uses: digitalocean/[email protected]
with:
app_name: gol2-review
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
images: '[{"name": "gol-2","image":{"registry_type": "DOCR","repository": "gol2","tag": "${{ env.tag }}"}}]'
Deploy-production:
if: github.event_name != 'workflow_dispatch' && github.ref == 'refs/heads/dev'
needs: Build
runs-on: ubuntu-latest
env:
tag: ${{ needs.Build.outputs.tag }}
environment:
name: production
url: https://gol2.io/
steps:
- name: DigitalOcean App Platform deployment
uses: digitalocean/[email protected]
with:
app_name: gol2
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
images: '[{"name": "gol2","image":{"registry_type": "DOCR","repository": "gol2","tag": "${{ env.tag }}"}}]'