Skip to content

Commit

Permalink
Merge pull request #2 from paritytech/oleg/ci_cd/add_ci
Browse files Browse the repository at this point in the history
Add github ci
  • Loading branch information
alvicsam authored Jan 16, 2024
2 parents 2f0a265 + 56eaff8 commit 1c3e5e4
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 6 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: build image
on:
pull_request:
push:
branches:
- master
tags:
- v*
env:
IMAGE_NAME: paritytech/polkadot-hub-app

jobs:
build_only:
name: Build Docker image
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: false
build-args: |
VCS_REF="${{ github.sha }}"
BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
tags: |
${{ env.IMAGE_NAME }}:${{ github.sha }}
${{ env.IMAGE_NAME }}:latest
build_and_push:
name: Build Docker image and push it to Docker Hub
if: ${{ github.ref == 'refs/heads/master' || github.ref_type == 'tag' }}
runs-on: ubuntu-latest
environment: master_and_tags
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Prepare Docker environment
run: |
echo IMAGE_TAG=$(if [ "$GITHUB_REF" == "refs/heads/master" ]; then echo "master-${GITHUB_SHA::7}"; else echo "$GITHUB_REF_NAME"; fi) >> $GITHUB_ENV
echo "Docker image will be published with the tag: ${{ env.IMAGE_TAG }}!"
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}

- name: Build and push Docker image from master
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: ${{ github.ref == 'refs/heads/master' }}
build-args: |
VCS_REF="${{ github.sha }}"
BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
tags: |
${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
${{ env.IMAGE_NAME }}:latest
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
FROM node:latest

ARG VCS_REF=master
ARG BUILD_DATE=""
ARG REGISTRY_PATH="harbor.parity-mgmt.parity.io/parity-internal"
ARG PROJECT_NAME=""
# metadata
ARG VCS_REF
ARG BUILD_DATE
ARG PROJECT_NAME="polkadot-hub-app"

LABEL io.parity.image.authors="cicd-team@parity.io" \
io.parity.image.vendor="Parity Technologies" \
io.parity.image.title="${REGISTRY_PATH}/${PROJECT_NAME}" \
io.parity.image.description="${PROJECT_NAME}" \
io.parity.image.title="${PROJECT_NAME}" \
io.parity.image.description="Polkadot Hub App is a self-hosted web app for managing offices, meeting rooms, events, and people profiles." \
io.parity.image.source="https://github.com/paritytech/${PROJECT_NAME}/blob/${VCS_REF}/Dockerfile" \
io.parity.image.documentation="https://github.com/paritytech/${PROJECT_NAME}/blob/${VCS_REF}/README.md" \
io.parity.image.revision="${VCS_REF}" \
Expand Down

0 comments on commit 1c3e5e4

Please sign in to comment.