diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 5e3ef3c..dd028ca 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -12,76 +12,76 @@ env: GIT_TAG: ${{ github.sha }} jobs: - # build-and-upload: - # runs-on: ubuntu-latest - # permissions: - # contents: read - # packages: write - - # steps: - # - name: Checkout code - # uses: actions/checkout@v2 - - # - name: Cache Node modules - # uses: actions/cache@v2 - # with: - # path: ~/.npm - # key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - # restore-keys: | - # ${{ runner.os }}-yarn- - - # - name: Set up Node.js - # uses: actions/setup-node@v2 - # with: - # node-version: '16' - - # - name: Install yarn dependencies - # run: yarn install - - # - name: Build tsp-ui - # run: yarn build - - # - name: Log in to the Container registry - # uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 - # with: - # registry: ${{ env.REGISTRY }} - # username: ${{ github.actor }} - # password: ${{ secrets.GITHUB_TOKEN }} - - # - name: Extract metadata (tags, labels) for Docker - # id: meta - # uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 - # with: - # images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - # tags: ${{ env.GIT_TAG }} + build-and-upload: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Cache Node modules + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '16' + + - name: Install yarn dependencies + run: yarn install + + - name: Build tsp-ui + run: yarn build + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: ${{ env.GIT_TAG }} - # - name: Build and push Docker image - # uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc - # with: - # context: . - # push: true - # tags: ${{ steps.meta.outputs.tags }} - # labels: ${{ steps.meta.outputs.labels }} - - # - uses: convictional/trigger-workflow-and-wait@v1.3.0 - # with: - # owner: WeiJiLab - # repo: tsp-docker-compose-file - # github_token: ${{ secrets.ZHU_TOKEN }} - # workflow_file_name: action.yml - # ref: master - # wait_interval: 5 - # inputs: '{"image_tag": "${{ env.GIT_TAG }}"}' - # propagate_failure: true - # trigger_workflow: true - # wait_workflow: true - - connect-to-ec2: + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - uses: convictional/trigger-workflow-and-wait@v1.3.0 + with: + owner: WeiJiLab + repo: tsp-docker-compose-file + github_token: ${{ secrets.ZHU_TOKEN }} + workflow_file_name: action.yml + ref: master + wait_interval: 5 + inputs: '{"image_tag": "${{ env.GIT_TAG }}"}' + propagate_failure: true + trigger_workflow: true + wait_workflow: true + + deploy-to-ec2: runs-on: ubuntu-latest permissions: id-token: write contents: write - # needs: build-and-upload + needs: build-and-upload steps: - name: Checkout code