-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' |