Merge pull request #71 from XinFinOrg/fix-masternode-login #100
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
name: Build and publish image | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- '*' | |
jobs: | |
backend_test_build_and_push_to_docker_registry: #disable backend in test branch | |
name: Test, build and publish backend image to docker hub | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
- name: Install dependencies | |
run: cd backend && npm install | |
- name: Docker login | |
env: | |
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}} | |
DOCKER_PASSWORD: ${{secrets.DOCKER_ACCESS_TOKEN}} | |
run: | | |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | |
- name: Determine Docker Image Name | |
id: image | |
run: | | |
if [[ "${{github.ref_name}}" == "master" ]]; then | |
echo "name=xinfinorg/subnet-stats-service:latest" >> $GITHUB_OUTPUT | |
else | |
echo "name=xinfinorg/subnet-stats-service:${{github.ref_name}}" >> $GITHUB_OUTPUT | |
fi | |
- name: Docker build and tag image | |
run: cd backend && docker build . --file Dockerfile --tag ${{ steps.image.outputs.name }} | |
- name: Docker push | |
run: docker push ${{ steps.image.outputs.name }} | |
frontend_test_build_and_push_to_docker_registry: | |
name: Test, build and publish frontend image to docker hub | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: frontend | |
steps: | |
- uses: actions/checkout@master | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
- name: Docker login | |
env: | |
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}} | |
DOCKER_PASSWORD: ${{secrets.DOCKER_ACCESS_TOKEN}} | |
run: | | |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | |
- name: Determine Docker Image Name | |
id: image | |
run: | | |
if [[ "${{github.ref_name}}" == "master" ]]; then | |
echo "name=xinfinorg/subnet-frontend:latest" >> $GITHUB_OUTPUT | |
else | |
echo "name=xinfinorg/subnet-frontend:${{github.ref_name}}" >> $GITHUB_OUTPUT | |
fi | |
- name: Docker build and tag image | |
run: docker build . --file Dockerfile --tag ${{ steps.image.outputs.name }} | |
- name: Test run docker | |
run: docker run --entrypoint /bin/sh ${{ steps.image.outputs.name }} -c 'yarn run build && yarn global add serve' | |
- name: Docker push | |
run: docker push ${{ steps.image.outputs.name }} |