Skip to content

Commit

Permalink
Change deployment flow (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
vokomarov authored May 28, 2023
2 parents 40f0ad6 + 39b81cc commit 6a11f1e
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 52 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: release

on:
workflow_dispatch:
release:
types: [ published ]

env:
REPO: cashtrack/api

jobs:
build:
runs-on: [self-hosted, Linux, x64]
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
if: github.event_name != 'pull_request'
uses: actions/checkout@v3

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
if: github.event_name != 'pull_request'
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REPO }}
tags: |
type=sha
type=semver,pattern={{version}}
# Setup BuildX
# https://github.com/docker/setup-buildx-action
- name: Setup BuildX
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true

# Build and push Docker image with Build (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
54 changes: 2 additions & 52 deletions .github/workflows/release.yml → .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: release
name: deploy

on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
cancel-in-progress: false

env:
REPO: cashtrack/api
Expand All @@ -16,57 +16,7 @@ env:
KUBECTL_BIN: https://storage.googleapis.com/kubernetes-release/release/v1.24.4/bin/linux/amd64/kubectl

jobs:
build:
runs-on: [self-hosted, Linux, x64]
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
if: github.event_name != 'pull_request'
uses: actions/checkout@v3

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
if: github.event_name != 'pull_request'
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REPO }}
tags: |
type=semver,pattern={{version}}
# Setup BuildX
# https://github.com/docker/setup-buildx-action
- name: Setup BuildX
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true

# Build and push Docker image with Build (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

deploy:
needs: [ build ]
runs-on: [self-hosted, Linux, x64]
permissions:
contents: read
Expand Down

0 comments on commit 6a11f1e

Please sign in to comment.