-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from paritytech/oleg/ci_cd/add_ci
Add github ci
- Loading branch information
Showing
2 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters