Skip to content

Commit

Permalink
(feat) use shared deployment gh workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
driiftkiing committed Jul 22, 2023
1 parent d8f4cab commit 3e2cca9
Showing 1 changed file with 7 additions and 43 deletions.
50 changes: 7 additions & 43 deletions .github/workflows/cd-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,18 @@ on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/youversion-api

jobs:
build-and-push-image:
name: Build & push image
runs-on: ubuntu-latest
timeout-minutes: 10
uses: driiftkiing/gh-workflows/.github/workflows/cd-docker-image.yml@main
with:
dockerfile: ./Dockerfile
imagename: ${{ github.repository_owner }}/youversion-api
secrets: inherit
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

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

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
${{ steps.meta.outputs.tags }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.package-version.outputs.current-version}}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit 3e2cca9

Please sign in to comment.