Skip to content

Commit

Permalink
[MISC] CI/CD pipelines for image publishing to dockerhub (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
deusebio authored Jan 10, 2023
1 parent 1c448e7 commit 960ecff
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup LXD
uses: whywaita/setup-lxd@v1
with:
lxd_version: latest/stable

- name: Install rockcraft
run: |
sudo snap install --classic --channel edge rockcraft
sudo iptables -F FORWARD
sudo iptables -P FORWARD ACCEPT
- name: Build ROCK
run: sudo rockcraft pack --verbose

- name: Upload locally built ROCK artifact
uses: actions/upload-artifact@v3
with:
name: spark-rock
path: "spark_*.rock"
6 changes: 6 additions & 0 deletions .github/workflows/on_pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
on:
pull_request:

jobs:
build:
uses: ./.github/workflows/build.yaml
10 changes: 10 additions & 0 deletions .github/workflows/on_push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
on:
push:
branches:
- '*.*/edge'

jobs:
publish:
name: Publish ROCK
uses: ./.github/workflows/publish.yaml
secrets: inherit
44 changes: 44 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
on:
workflow_call:
workflow_dispatch:

jobs:
build:
uses: ./.github/workflows/build.yaml
publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Docker
run: |
sudo snap install docker
sudo addgroup --system docker; sudo adduser $USER docker
newgrp docker
sudo snap disable docker; sudo snap enable docker
- name: Install skopeo
run: |
sudo snap install --devmode --channel edge skopeo
- name: Install yq
run: |
sudo snap install yq
- uses: actions/download-artifact@v3
with:
name: spark-rock

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

- name: Import and push to Docker Hub
run: |
version="$(cat rockcraft.yaml | yq e '.version')"
sudo skopeo \
--insecure-policy \
copy \
oci-archive:"spark_${version}_amd64.rock" \
docker-daemon:"dataplatformoci/spark:${version}"
docker push "dataplatformoci/spark:${version}"
2 changes: 1 addition & 1 deletion rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ summary: Spark ROCK
description: Spark ROCK
license: Apache-2.0

version: "0.1"
version: "3.3.1"
base: ubuntu:22.04
platforms:
amd64:
Expand Down

0 comments on commit 960ecff

Please sign in to comment.