refact(actions): use build & push action instead of makefile (#315)

Signed-off-by: shubham <shubham.bajpai@mayadata.io>
This commit is contained in:
Shubham Bajpai 2021-04-27 19:31:08 +05:30 committed by GitHub
parent cb3ae22f7a
commit be4334f7c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 121 additions and 19 deletions

View file

@ -13,10 +13,21 @@
# limitations under the License.
name: build
on: ['push']
on:
create:
push:
branches:
- master
- 'v*'
paths-ignore:
- 'docs/**'
- 'changelogs/**'
- 'deploy/helm/**'
- 'CHANGELOG.md'
jobs:
lint:
if: ${{ (github.event.ref_type == 'branch') }} # to ignore builds on release
runs-on: ubuntu-latest
steps:
- name: Checkout
@ -33,6 +44,7 @@ jobs:
unit-test:
if: ${{ (github.event.ref_type == 'branch') }} # to ignore builds on release
runs-on: ubuntu-latest
steps:
- name: Checkout
@ -97,6 +109,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Set Image Org
# sets the default IMAGE_ORG to openebs
run: |
[ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}}
echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV
- name: Set Tag
run: |
BRANCH="${GITHUB_REF##*/}"
@ -107,10 +125,28 @@ jobs:
echo "TAG=${CI_TAG}" >> $GITHUB_ENV
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
- name: Set Build Date
id: date
run: |
echo "::set-output name=DATE::$(date -u +'%Y-%m-%dT%H:%M:%S%Z')"
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
# add each registry to which the image needs to be pushed here
images: |
${{ env.IMAGE_ORG }}/zfs-driver
quay.io/${{ env.IMAGE_ORG }}/zfs-driver
tag-latest: false
tag-custom-only: true
tag-custom: |
${{ env.TAG }}
- name: Print Tag info
run: |
echo "BRANCH: ${BRANCH}"
echo "TAG: ${TAG}"
echo "${{ steps.docker_meta.outputs.tags }}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
@ -129,9 +165,24 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Quay
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Build & Push Image
env:
IMAGE_ORG: ${{ secrets.IMAGE_ORG}}
run: |
make docker.buildx.csi-driver
make buildx.push.csi-driver
uses: docker/build-push-action@v2
with:
context: .
file: ./buildscripts/zfs-driver/zfs-driver.Dockerfile
push: true
platforms: linux/amd64, linux/arm64
tags: |
${{ steps.docker_meta.outputs.tags }}
build-args: |
DBUILD_DATE=${{ steps.date.outputs.DATE }}
DBUILD_REPO_URL=https://github.com/openebs/zfs-localpv
DBUILD_SITE_URL=https://openebs.io
BRANCH=${{ env.BRANCH }}

View file

@ -18,6 +18,9 @@ on:
pull_request:
paths-ignore:
- 'deploy/helm/**'
- 'docs/**'
- 'changelogs/**'
- 'CHANGELOG.md'
branches:
# on pull requests to master and release branches
- master
@ -116,7 +119,12 @@ jobs:
with:
version: v0.4.2
- name: Build Image
env:
IMG_RESULT: cache
run: make docker.buildx.csi-driver
- name: Build
uses: docker/build-push-action@v2
with:
context: .
file: ./buildscripts/zfs-driver/zfs-driver.Dockerfile
push: false
platforms: linux/amd64, linux/arm64
tags: |
openebs/zfs-driver:ci

View file

@ -14,7 +14,9 @@
name: release
on:
push:
release:
types:
- "created"
tags:
- 'v*'
@ -24,6 +26,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set Image Org
# sets the default IMAGE_ORG to openebs
run: |
[ -z "${{ secrets.IMAGE_ORG }}" ] && IMAGE_ORG=openebs || IMAGE_ORG=${{ secrets.IMAGE_ORG}}
echo "IMAGE_ORG=${IMAGE_ORG}" >> $GITHUB_ENV
- name: Set Tag
run: |
@ -31,8 +39,26 @@ jobs:
echo "TAG=${TAG}" >> $GITHUB_ENV
echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV
- name: Set Build Date
id: date
run: |
echo "::set-output name=DATE::$(date -u +'%Y-%m-%dT%H:%M:%S%Z')"
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
# add each registry to which the image needs to be pushed here
images: |
${{ env.IMAGE_ORG }}/zfs-driver
quay.io/${{ env.IMAGE_ORG }}/zfs-driver
tag-latest: true
tag-semver: |
{{version}}
- name: Print Tag info
run: |
echo "${{ steps.docker_meta.outputs.tags }}"
echo "RELEASE TAG: ${RELEASE_TAG}"
- name: Set up QEMU
@ -51,10 +77,25 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Quay
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Build & Push Image
env:
IMAGE_ORG: ${{ secrets.IMAGE_ORG}}
run: |
make docker.buildx.csi-driver
make buildx.push.csi-driver
uses: docker/build-push-action@v2
with:
context: .
file: ./buildscripts/zfs-driver/zfs-driver.Dockerfile
push: true
platforms: linux/amd64, linux/arm64
tags: |
${{ steps.docker_meta.outputs.tags }}
build-args: |
DBUILD_DATE=${{ steps.date.outputs.DATE }}
DBUILD_REPO_URL=https://github.com/openebs/zfs-localpv
DBUILD_SITE_URL=https://openebs.io
RELEASE_TAG=${{ env.RELEASE_TAG }}

View file

@ -46,6 +46,7 @@ echo '
cat deploy/yamls/zfs.openebs.io_zfsvolumes.yaml >> deploy/yamls/zfsvolume-crd.yaml
rm deploy/yamls/zfs.openebs.io_zfsvolumes.yaml
cp deploy/yamls/zfsvolume-crd.yaml deploy/helm/charts/crds/zfsvolume.yaml
echo '
@ -61,7 +62,7 @@ echo '
cat deploy/yamls/zfs.openebs.io_zfssnapshots.yaml >> deploy/yamls/zfssnapshot-crd.yaml
rm deploy/yamls/zfs.openebs.io_zfssnapshots.yaml
cp deploy/yamls/zfssnapshot-crd.yaml deploy/helm/charts/crds/zfssnapshot.yaml
echo '
@ -77,7 +78,7 @@ echo '
cat deploy/yamls/zfs.openebs.io_zfsbackups.yaml >> deploy/yamls/zfsbackup-crd.yaml
rm deploy/yamls/zfs.openebs.io_zfsbackups.yaml
cp deploy/yamls/zfsbackup-crd.yaml deploy/helm/charts/crds/zfsbackup.yaml
echo '
@ -93,6 +94,7 @@ echo '
cat deploy/yamls/zfs.openebs.io_zfsrestores.yaml >> deploy/yamls/zfsrestore-crd.yaml
rm deploy/yamls/zfs.openebs.io_zfsrestores.yaml
cp deploy/yamls/zfsrestore-crd.yaml deploy/helm/charts/crds/zfsrestore.yaml
## create the operator file using all the yamls