# This workflow will run tests using node and then publish a package to GitHub Container Registry and Docker Hub Regitry when a pushed into main branches # This file was contributed by Edwin Betancourt from ERP Consultores y Asociados, C.A name: Push Main Branches on: # Triggers the workflow on push events but only for the develop branch push: branches: - develop jobs: # Build dist application ADempiere-Vue build-app: name: Build dist ADempiere-Vue runs-on: ubuntu-latest strategy: matrix: node-version: [12.x] steps: - name: Check out the repo uses: actions/checkout@v2 - name: Node configuration uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} cache: 'npm' - name: Set tag version into config file run: sed -i "s|releaseNoForDocumentation|${{ github.event.release.tag_name }}|g" config/default.json - name: Install packages run: npm ci - name: Run test run: npm test - name: Compile dist run: npm run build:prod --if-present - name: Upload dist app uses: actions/upload-artifact@v2 with: name: adempiere-vue path: dist # Publish docker image in Github Container Registry to application push-imame-ghcr: name: Push Docker image to GitHub Container needs: - build-app runs-on: ubuntu-latest steps: - name: Check out the repo uses: actions/checkout@v2 - name: Download build dist app uses: actions/download-artifact@v2 with: name: adempiere-vue path: dist - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set Lower Case to owner and repository run: | echo "OWNER_LC=${OWNER,,}" >> ${GITHUB_ENV} echo "REPO_LC=${NAME,,}" >> ${GITHUB_ENV} env: OWNER: '${{ github.repository_owner }}' NAME: '${{ github.event.repository.name }}' - name: Get branch name id: branch-name uses: tj-actions/branch-names@v4.8 - name: Build and push Docker image uses: docker/build-push-action@v2 with: context: . file: ./build/Dockerfile.prod push: true tags: | ghcr.io/${{ env.OWNER_LC }}/${{ env.REPO_LC }}:${{ steps.branch-name.outputs.current_branch }} ghcr.io/${{ env.OWNER_LC }}/${{ env.REPO_LC }}:${{ github.sha }} - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} # Publish docker image in Docker Hub registry to application push-imame-dhr: name: Push Docker image to Docker Hub needs: - build-app runs-on: ubuntu-latest steps: - name: Check out the repo uses: actions/checkout@v2 - name: Download build dist app uses: actions/download-artifact@v2 with: name: adempiere-vue path: dist - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: # CONFIGURE DOCKER SECRETS INTO REPOSITORY username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Set Lower Case to owner and repository run: | ORG=$OWNER if [ -n "${{ secrets.DOCKERHUB_ORG }}" ]; then echo "Set secret DOCKERHUB_ORG as namespace" ORG=${{ secrets.DOCKERHUB_ORG }} else echo "Set OWNER ($OWNER) as namespace " fi echo "ORG_LC=${ORG,,}" >> ${GITHUB_ENV} echo "OWNER_LC=${OWNER,,}" >> ${GITHUB_ENV} echo "REPO_LC=${NAME,,}" >> ${GITHUB_ENV} env: # to docker image namespace OWNER: '${{ github.repository_owner }}' NAME: '${{ github.event.repository.name }}' - name: Get branch name id: branch-name uses: tj-actions/branch-names@v4.8 - name: Build and push Docker image uses: docker/build-push-action@v2 with: context: . file: ./build/Dockerfile.prod push: true tags: | ${{ env.ORG_LC }}/${{ env.REPO_LC }}:${{ steps.branch-name.outputs.current_branch }} ${{ env.ORG_LC }}/${{ env.REPO_LC }}:${{ github.sha }} - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }}