Skip to content

Commit

Permalink
add github actions to build image
Browse files Browse the repository at this point in the history
  • Loading branch information
tbho committed Sep 19, 2024
1 parent 805f46e commit fc3b321
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,41 @@ jobs:
- name: test-image
run: bin/ci

push:
name: Push to production server
build:
name: Build image and push to Gihub Registry (production branch only)
needs: test
runs-on: ubuntu-latest

steps:
-
name: checkout-repo
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Push to dokku
uses: dokku/[email protected]
with:
git_remote_url: ${{ secrets.GIT_REMOTE_URL }}
ssh_private_key: ${{ secrets.DOKKU_SSH_KEY }}
if: github.ref == 'refs/heads/production'
# Step 1: Check out the repository
- name: Checkout code
uses: actions/checkout@v3

# Step 2: Set up Docker Buildx (for cross-platform builds, if needed)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Step 3: Log in to GitHub Container Registry
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Step 4: Build the Docker image
- name: Build Docker image
run: |
docker build -t ghcr.io/${{ github.repository }}:${{ github.sha }} .
# Step 5: Push the Docker image to GitHub Container Registry
- name: Push Docker image to GitHub Container Registry
run: |
docker push ghcr.io/${{ github.repository }}:${{ github.sha }}
# Optional Step 6: Add latest tag and push it as well
- name: Tag image as latest and push
run: |
docker tag ghcr.io/${{ github.repository }}:${{ github.sha }} ghcr.io/${{ github.repository }}:latest
docker push ghcr.io/${{ github.repository }}:latest
if: github.ref == 'refs/heads/production'

0 comments on commit fc3b321

Please sign in to comment.