Skip to content

Commit

Permalink
separate build and release pipelines.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmotevalli committed Jan 11, 2024
1 parent c90330c commit 9a9a9b2
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 78 deletions.
101 changes: 23 additions & 78 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,89 +1,34 @@
name: Build CKAN Docker

name: Build Docker Image

on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
# -
- deploy
pull_request:
branches:
# - master
- deploy

- master
- dev
# - build-pipeline
jobs:
build:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

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

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and Push Docker image
uses: docker/build-push-action@v2
with:
- uses: actions/checkout@v2
with:
submodules: true

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

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and Push Docker image
uses: docker/build-push-action@v2
with:
context: ./ckan
file: ./ckan/Dockerfile
push: true
tags: |
benmotevalli/ckan-auscope:latest
benmotevalli/ckan-auscope:${{ github.sha }}
benmotevalli/ckan-auscope:${{ github.ref_name }}
# Original Build
# ==============
# name: Build CKAN Docker

# on:
# # Trigger the workflow on push or pull request,
# # but only for the master branch
# push:
# branches:
# - master
# pull_request:
# branches:
# - master

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

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

# - name: Set up QEMU
# uses: docker/setup-qemu-action@v1

# - name: NGINX build
# uses: docker/build-push-action@v2
# with:
# context: ./nginx
# file: ./nginx/Dockerfile
# push: false
# tags: kowhai/ckan-docker-nginx:test-build-only

# - name: PostgreSQL build
# uses: docker/build-push-action@v2
# with:
# context: ./postgresql
# file: ./postgresql/Dockerfile
# push: false
# tags: kowhai/ckan-docker-postgresql:test-build-only

# - name: CKAN build
# uses: docker/build-push-action@v2
# with:
# context: ./ckan
# file: ./ckan/Dockerfile
# push: false
# tags: kowhai/ckan-docker-ckan:test-build-only
benmotevalli/ckan-auscope:${{ github.ref == 'refs/heads/master' && 'latest' || 'dev' }}
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Versioned Release Image

on:
workflow_dispatch:
inputs:
releaseType:
description: 'Release Type (patch/minor/major)'
required: true
default: 'patch'
branches:
- master
# - build-pipeline

jobs:
release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
# if: github.ref == 'refs/heads/build-pipeline'
steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install bump2version
run: pip install bump2version

- name: Bump version
id: bump_version
run: |
bump2version ${{ github.event.inputs.releaseType }} --list
echo "New version: $(grep 'current_version = ' setup.cfg | sed -r 's/current_version = //')"
echo "::set-output name=version::$(grep 'current_version = ' setup.cfg | sed -r 's/current_version = //')"
- name: Push the tags and changes
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
git push origin --tags
git push
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and Push Versioned Docker image
uses: docker/build-push-action@v2
with:
context: ./ckan
file: ./ckan/Dockerfile
push: true
tags: benmotevalli/ckan-auscope:${{ steps.bump_version.outputs.version }}
4 changes: 4 additions & 0 deletions ckan/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[bumpversion]
current_version = 0.1.0
commit = True
tag = True

0 comments on commit 9a9a9b2

Please sign in to comment.