Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated ci/cd pipelines #48

Merged
merged 2 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/cd-dev.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: CD Dev
name: cd-dev

on:
workflow_run:
workflows: ["CI"]
workflows: ["ci-tests"]
types:
- completed

Expand Down Expand Up @@ -36,7 +36,6 @@ jobs:
run: |
echo "VITE_API_URL=${{ secrets.VITE_API_URL_DEV }}" > .env


- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
Expand All @@ -45,8 +44,8 @@ jobs:
file: ./Dockerfile
push: true
tags: |
shampiniony/dishdash-miniapp:dev
shampiniony/dishdash-miniapp:dev-${{ env.COMMIT_SHORT_SHA }}
${{ secrets.DOCKER_USERNAME }}/dishdash-miniapp:dev
${{ secrets.DOCKER_USERNAME }}/dishdash-miniapp:dev-${{ env.COMMIT_SHORT_SHA }}

- name: Trigger Watchtower to update dev container
shell: bash
Expand Down
27 changes: 13 additions & 14 deletions .github/workflows/cd-production.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
name: Publish Docker image
name: CD-prod

on:
workflow_run:
workflows: ["CI"]
types:
- completed
workflow_dispatch:
inputs:
tag_name:
description: Write tag for deploy
required: true

jobs:
ci-tests:
uses: .github/workflows/ci-tests.yaml

push_to_registry:
name: Push Docker image to Docker Hub
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' }}
needs: ci-tests
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != '')
runs-on: ubuntu-latest
permissions:
packages: write
Expand All @@ -20,12 +25,6 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set short git commit SHA
id: vars
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
Expand All @@ -44,8 +43,8 @@ jobs:
file: ./Dockerfile
push: true
tags: |
shampiniony/dishdash-miniapp:latest
shampiniony/dishdash-miniapp:${{ env.COMMIT_SHORT_SHA }}
${{ secrets.DOCKER_USERNAME }}/dishdash-miniapp:latest
${{ secrets.DOCKER_USERNAME }}/dishdash-miniapp:${{ github.event.inputs.tag_name }}

- name: Trigger watchtower to update container(s)
shell: bash
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: ci-build

on:
workflow_call: {}
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build docker image
run: docker compose build --progress plain
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
name: CI
name: ci-tests

on:
push:
branches: [ "main", "dev" ]
pull_request:
branches: [ "main", "dev" ]
on: [workflow_call]

jobs:

build:

runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

Expand All @@ -27,10 +20,4 @@ jobs:
run: yarn lint

- name: Run Unit Tests
run: yarn test

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build docker image
run: docker compose build
run: yarn test
Loading