Github action to push to Docker Hub and create Github release (#169)
* Adding a github action to push to Docker Hub and create Github release when a tag is created on master branch. * Extracting the tag from the github ref and only tagging the Docker image with the relevant tag.
This commit is contained in:
parent
74da0f117e
commit
015c56e1a6
2
.github/workflows/client.yml
vendored
2
.github/workflows/client.yml
vendored
|
|
@ -37,7 +37,7 @@ jobs:
|
|||
env:
|
||||
cache-name: cache-yarn-dependencies
|
||||
with:
|
||||
# maven dependencies are stored in `~/.m2` on Linux/macOS
|
||||
# npm dependencies are stored in `~/.npm` on Linux/macOS
|
||||
path: ~/.npm
|
||||
key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
|
|
|
|||
123
.github/workflows/github-release.yml
vendored
Normal file
123
.github/workflows/github-release.yml
vendored
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
name: Appsmith Github Release Workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: master
|
||||
# Only trigger if a tag has been created and pushed to this branch
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build-client:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: app/client
|
||||
|
||||
steps:
|
||||
# Checkout the code
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Use Node.js 10.16.3
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '10.16.3'
|
||||
|
||||
# Retrieve npm dependencies from cache. After a successful run, these dependencies are cached again
|
||||
- name: Cache npm dependencies
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cache-yarn-dependencies
|
||||
with:
|
||||
# npm dependencies are stored in `~/.m2` on Linux/macOS
|
||||
path: ~/.npm
|
||||
key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.OS }}-node-
|
||||
${{ runner.OS }}-
|
||||
|
||||
# Install all the dependencies
|
||||
- name: Install dependencies
|
||||
run: yarn install
|
||||
|
||||
- name: Set the build environment based on the branch
|
||||
id: vars
|
||||
run: |
|
||||
REACT_APP_ENVIRONMENT="PRODUCTION"
|
||||
echo ::set-output name=REACT_APP_ENVIRONMENT::${REACT_APP_ENVIRONMENT}
|
||||
|
||||
- name: Create the bundle
|
||||
run: REACT_APP_ENVIRONMENT=${{steps.vars.outputs.REACT_APP_ENVIRONMENT}} yarn build
|
||||
|
||||
- name: Get the version
|
||||
id: get_version
|
||||
run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
|
||||
|
||||
# Build Docker image and push to Docker Hub
|
||||
- name: Push production image to Docker Hub with commit tag
|
||||
run: |
|
||||
docker build -t appsmith/appsmith-editor:${{steps.get_version.outputs.tag}} .
|
||||
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
|
||||
docker push appsmith/appsmith-editor
|
||||
|
||||
build-server:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: app/server
|
||||
|
||||
steps:
|
||||
# Checkout the code
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
# Setup Java
|
||||
- name: Set up JDK 1.11
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.11
|
||||
|
||||
# Retrieve maven dependencies from cache. After a successful run, these dependencies are cached again
|
||||
- name: Cache maven dependencies
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cache-maven-dependencies
|
||||
with:
|
||||
# maven dependencies are stored in `~/.m2` on Linux/macOS
|
||||
path: ~/.m2
|
||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: ${{ runner.os }}-m2
|
||||
|
||||
# Build the code
|
||||
- name: Build without running any tests
|
||||
run: mvn -B package -DskipTests
|
||||
|
||||
- name: Get the version
|
||||
id: get_version
|
||||
run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
|
||||
|
||||
# Build Docker image and push to Docker Hub
|
||||
- name: Push image to Docker Hub
|
||||
run: |
|
||||
docker build -t appsmith/appsmith-server:${{steps.get_version.outputs.tag}} .
|
||||
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
|
||||
docker push appsmith/appsmith-server
|
||||
|
||||
create-release:
|
||||
needs:
|
||||
- build-server
|
||||
- build-client
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Creating the release on Github
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: Release ${{ github.ref }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
Loading…
Reference in New Issue
Block a user