Skip to content

Commit

Permalink
Reorganise Github Actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
vokomarov committed May 30, 2023
1 parent 8b1c71f commit 2aed7dc
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 55 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: build

on:
workflow_dispatch:
release:
types: [ published ]

env:
REPO: cashtrack/mysql-backup

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 }}
59 changes: 6 additions & 53 deletions .github/workflows/release.yml → .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: Release
name: deploy

on:
release:
types: [ published ]
workflow_dispatch:

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

env:
REPO: cashtrack/mysql-backup
Expand All @@ -13,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
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# MySQL Backup

[![Release](https://github.com/cash-track/mysql-backup/actions/workflows/release.yml/badge.svg)](https://github.com/cash-track/mysql-backup/actions/workflows/release.yml)

A simple tool to automate backups flow for MySQL database.

## Workflow
Expand Down

0 comments on commit 2aed7dc

Please sign in to comment.