diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..08a81ab --- /dev/null +++ b/.github/workflows/build.yml @@ -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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/deploy.yml similarity index 56% rename from .github/workflows/release.yml rename to .github/workflows/deploy.yml index 67b08b1..9c2690a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/deploy.yml @@ -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 @@ -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 diff --git a/README.md b/README.md index 18de1e0..ce66781 100644 --- a/README.md +++ b/README.md @@ -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