From c12ad64935fe1da27b172e7da7a3255df5ebfb5d Mon Sep 17 00:00:00 2001 From: Vladlen Fedosov Date: Mon, 20 Apr 2020 14:26:32 +0300 Subject: [PATCH] fix: fixed release workflow --- .github/workflows/ci.yml | 83 ++++++++++++++++++++++++++++++++++ .github/workflows/ilc.yml | 41 ----------------- .github/workflows/registry.yml | 41 ----------------- .github/workflows/release.yml | 44 ++++++++++++++++-- README.md | 3 +- 5 files changed, 124 insertions(+), 88 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/ilc.yml delete mode 100644 .github/workflows/registry.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..d7208a3f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,83 @@ +name: CI + +on: + push: + branches: + - '**' + tags-ignore: + - '**' + +jobs: + build_ilc: + name: Build ILC + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + + - name: Docker ilc auth + run: echo "${{ secrets.DOCKER_HUB_TOKEN_NC }}" | docker login --username namecheaprnd --password-stdin + + - name: Build the Docker image + run: | + cd ./ilc/ + docker build . --tag ilc:tmp + + - name: Run tests + run: docker run ilc:tmp npm run test + + - name: Calc tags + id: tags + run: | + BRANCH=$(echo ${GITHUB_REF} | cut -d '/' -f 3-99) + LATEST=$([ "$BRANCH" == "master" ] && echo "latest,${GITHUB_SHA:0:7}," || echo "") + DOCKER_TAGS="$LATEST${BRANCH//\//_}" + echo "Tags that will be used: $DOCKER_TAGS" + echo ::set-output name=docker_tags::$DOCKER_TAGS + + - name: Push image + run: | + TAGS="${{ steps.tags.outputs.docker_tags }}" + + for i in ${TAGS//,/ } + do + docker tag ilc:tmp namecheap/ilc:$i + docker push namecheap/ilc:$i + done + + build_registry: + name: Build Registry + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + + - name: Docker registry auth + run: echo "${{ secrets.DOCKER_HUB_TOKEN_NC }}" | docker login --username namecheaprnd --password-stdin + + - name: Build the Docker image + run: | + cd ./registry/ + docker build . --tag registry:tmp + + - name: Run tests + run: docker run registry:tmp npm run test:ci + + - name: Calc tags + id: tags + run: | + BRANCH=$(echo ${GITHUB_REF} | cut -d '/' -f 3-99) + LATEST=$([ "$BRANCH" == "master" ] && echo "latest,${GITHUB_SHA:0:7}," || echo "") + DOCKER_TAGS="$LATEST${BRANCH//\//_}" + echo "Tags that will be used: $DOCKER_TAGS" + echo ::set-output name=docker_tags::$DOCKER_TAGS + + - name: Push image + run: | + TAGS="${{ steps.tags.outputs.docker_tags }}" + + for i in ${TAGS//,/ } + do + docker tag registry:tmp namecheap/ilc_registry:$i + docker push namecheap/ilc_registry:$i + done diff --git a/.github/workflows/ilc.yml b/.github/workflows/ilc.yml deleted file mode 100644 index f46d1fc6..00000000 --- a/.github/workflows/ilc.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: ILC - -on: [push] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - - name: Docker ilc auth - run: echo "${{ secrets.DOCKER_HUB_TOKEN_NC }}" | docker login --username namecheaprnd --password-stdin - - - name: Build the Docker image - run: | - cd ./ilc/ - docker build . --tag ilc:tmp - - - name: Run tests - run: docker run ilc:tmp npm run test - - - name: Calc tags - id: tags - run: | - BRANCH=$(echo ${GITHUB_REF} | cut -d '/' -f 3-99) - LATEST=$([ "$BRANCH" == "master" ] && echo "latest,${GITHUB_SHA:0:7}," || echo "") - DOCKER_TAGS="$LATEST${BRANCH//\//_}" - echo "Tags that will be used: $DOCKER_TAGS" - echo ::set-output name=docker_tags::$DOCKER_TAGS - - - name: Push image - run: | - TAGS="${{ steps.tags.outputs.docker_tags }}" - - for i in ${TAGS//,/ } - do - docker tag ilc:tmp namecheap/ilc:$i - docker push namecheap/ilc:$i - done diff --git a/.github/workflows/registry.yml b/.github/workflows/registry.yml deleted file mode 100644 index e080d2c0..00000000 --- a/.github/workflows/registry.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Registry - -on: [push] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - - name: Docker registry auth - run: echo "${{ secrets.DOCKER_HUB_TOKEN_NC }}" | docker login --username namecheaprnd --password-stdin - - - name: Build the Docker image - run: | - cd ./registry/ - docker build . --tag registry:tmp - - - name: Run tests - run: docker run registry:tmp npm run test:ci - - - name: Calc tags - id: tags - run: | - BRANCH=$(echo ${GITHUB_REF} | cut -d '/' -f 3-99) - LATEST=$([ "$BRANCH" == "master" ] && echo "latest,${GITHUB_SHA:0:7}," || echo "") - DOCKER_TAGS="$LATEST${BRANCH//\//_}" - echo "Tags that will be used: $DOCKER_TAGS" - echo ::set-output name=docker_tags::$DOCKER_TAGS - - - name: Push image - run: | - TAGS="${{ steps.tags.outputs.docker_tags }}" - - for i in ${TAGS//,/ } - do - docker tag registry:tmp namecheap/ilc_registry:$i - docker push namecheap/ilc_registry:$i - done diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0620e14d..4565a759 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,11 @@ jobs: - name: Calc tags id: tags run: | + function isSemver() { + echo "${1}" | grep -Eq '^refs/tags/v?([0-9]+)\.([0-9+])\.([0-9]+)(-[a-zA-Z]+(\.[0-9]+)?)?$' + } + + echo $GITHUB_REF if ! isSemver "${GITHUB_REF}"; then echo "Invalid tag name format. Use semver style. Ex: v1.2.3" exit 1 @@ -27,10 +32,7 @@ jobs: echo "Tags that will be used: $DOCKER_TAGS" echo ::set-output name=docker_tags::$DOCKER_TAGS - - function isSemver() { - echo "${1}" | grep -Eq '^refs/tags/v?([0-9]+)\.([0-9+])\.([0-9]+)(-[a-zA-Z]+(\.[0-9]+)?)?$' - } + echo ::set-output name=tag::$(echo $GITHUB_REF | cut -d / -f 3) - name: Pull & tag images for release run: | @@ -50,3 +52,37 @@ jobs: docker tag namecheap/ilc_registry:${GITHUB_SHA:0:7} namecheap/ilc_registry:$i docker push namecheap/ilc_registry:$i done + + - name: Get release description + id: get_release + uses: octokit/request-action@v2.x + with: + route: GET /repos/:repository/releases/tags/:tag_name + repository: ${{ github.repository }} + tag_name: ${{ steps.tags.outputs.tag }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Parse release info + id: parse_release + uses: gr2m/get-json-paths-action@v1.x + with: + json: ${{ steps.get_release.outputs.data }} + id: "id" + body: "body" + + - uses: octokit/request-action@v2.x + id: update_check_run + with: + route: PATCH /repos/:repository/releases/:release_id + repository: ${{ github.repository }} + release_id: ${{ steps.parse_release.outputs.id }} + body: | + | + ${{ steps.parse_release.outputs.body }} + + **Docker images:** + - [namecheap/ilc](https://hub.docker.com/r/namecheap/ilc): `${{ steps.tags.outputs.docker_tags }}` + - [namecheap/ilc_registry](https://hub.docker.com/r/namecheap/ilc_registry): `${{ steps.tags.outputs.docker_tags }}` + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index efc374a7..1d7568cb 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,7 @@ ---- [![Demo website](./docs/assets/demo-website.svg)](http://demo.microfrontends.online/) -[![Actions Status](https://github.com/namecheap/ilc/workflows/Registry/badge.svg)](https://github.com/namecheap/ilc/actions) -[![Actions Status](https://github.com/namecheap/ilc/workflows/ILC/badge.svg)](https://github.com/namecheap/ilc/actions) +[![Actions Status](https://github.com/namecheap/ilc/workflows/CI/badge.svg)](https://github.com/namecheap/ilc/actions) [![Docker Pulls](https://img.shields.io/docker/pulls/namecheap/ilc?logo=docker&logoColor=white)](https://hub.docker.com/r/namecheap/ilc) Isomorphic Layout Composer (ILC) - layout service that compose a web page from fragment services.