Skip to content

Commit

Permalink
chore: test new cd
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasschultheiss committed Oct 19, 2024
1 parent c9c28c1 commit 89fa774
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 42 deletions.
62 changes: 24 additions & 38 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,31 @@ on:
- 'main'

jobs:
docker:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/prsm/crystal-nest
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# Step 1: Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3

# Step 2: Set up Docker
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
uses: docker/setup-buildx-action@v2

# Step 3: Log in to DockerHub
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
context: .
secrets: |
GIT_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: production
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Step 4: Build the Docker image targeting production
- name: Build and tag Docker image
run: |
docker build --target production -t ${{ secrets.DOCKERHUB_USERNAME }}/crystal:${{ github.ref_name }} .
# Step 5: Push the Docker image to DockerHub
- name: Push Docker image
run: |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/crystal:${{ github.ref_name }}
9 changes: 5 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ services:
bot:
restart: unless-stopped
container_name: dev_bot
build:
context: ./
dockerfile: Dockerfile
target: production
image: ghcr.io/prsm/crystal-nest:develop
# build:
# context: ./
# dockerfile: Dockerfile
# target: production
env_file:
- ./.env

Expand Down

0 comments on commit 89fa774

Please sign in to comment.