Skip to content

Commit

Permalink
Merge pull request #27 from thomasoca/add-actions-to-publish-image
Browse files Browse the repository at this point in the history
Add actions to publish image
  • Loading branch information
thomasoca committed Jun 13, 2023
2 parents 7734336 + ea7b75b commit dcf8197
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
26 changes: 25 additions & 1 deletion .github/workflows/production-release.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,42 @@
name: Deploy to production environment

# Run workflow on every push to main branch.
# This workflow will build docker image with latest tag and push it to container registry
on:
push:
branches: [main]
workflow_dispatch: # So it can be triggered manually if needed

env:
IMAGE_NAME: cv-generator
GHCR_REGISTRY: ghcr.io
GHCR_REPOSITORY: thomasoca

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

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

- name: Log in to GHCR
uses: docker/login-action@v1
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_REPOSITORY }}/${{ env.IMAGE_NAME }}:latest

- name: Push and Release a Docker container to the production
- name: Trigger Render API to start the production deployment
uses: johnbeynon/render-deploy-action@v0.0.8
with:
service-id: ${{ secrets.RENDER_SERVICE_NAME }}
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/stable-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Push stable release image

# Run workflow on every new stable release tag
# This workflow will build docker image with stable tag and push it to container registry
on:
release:
types: [published]

env:
IMAGE_NAME: cv-generator
GHCR_REGISTRY: ghcr.io
GHCR_REPOSITORY: thomasoca

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

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

- name: Log in to GHCR
uses: docker/login-action@v1
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_REPOSITORY }}/${{ env.IMAGE_NAME }}:stable

0 comments on commit dcf8197

Please sign in to comment.