From 94f6ff0aefa34893fb0dcea32ae23ba735f15568 Mon Sep 17 00:00:00 2001 From: Umputun Date: Sun, 8 Aug 2021 14:48:13 -0500 Subject: [PATCH] add ci build for site --- .github/workflows/ci-site.yml | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/ci-site.yml diff --git a/.github/workflows/ci-site.yml b/.github/workflows/ci-site.yml new file mode 100644 index 00000000..b9c6fd57 --- /dev/null +++ b/.github/workflows/ci-site.yml @@ -0,0 +1,64 @@ +name: frontend + +on: + push: + branches: + tags: + paths: + - ".github/workflows/ci-site.yml" + - "site/**" + pull_request: + paths: + - ".github/workflows/ci-site.yml" + - "site/**" + +jobs: + + build: + runs-on: ubuntu-latest + + steps: + - name: checkout + - uses: actions/checkout@v2 + + - name: set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: available platforms + run: echo ${{ steps.buildx.outputs.platforms }} + + - name: build and deploy master image to ghcr.io and dockerhub + if: ${{ github.ref == 'refs/heads/master' }} + env: + GITHUB_PACKAGE_TOKEN: ${{ secrets.PKG_TOKEN }} + USERNAME: ${{ github.actor }} + GITHUB_SHA: ${{ github.sha}} + GITHUB_REF: ${{ github.ref}} + run: | + ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)" + echo GITHUB_REF - $ref + echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin + docker buildx build --push \ + --build-arg CI=github --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \ + --platform linux/amd64,linux/arm/v7,linux/arm64 \ + -t ghcr.io/${USERNAME}/remark24-site:${ref} . + + - name: deploy tagged (latest) to ghcr.io and dockerhub + if: ${{ startsWith(github.ref, 'refs/tags/') }} + env: + GITHUB_PACKAGE_TOKEN: ${{ secrets.PKG_TOKEN }} + USERNAME: ${{ github.actor }} + GITHUB_SHA: ${{ github.sha}} + GITHUB_REF: ${{ github.ref}} + run: | + ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)" + echo GITHUB_REF - $ref + echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin + docker buildx build --push \ + --build-arg CI=github --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \ + --platform linux/amd64,linux/arm/v7,linux/arm64 \ + -t ghcr.io/${USERNAME}/remark24-site:${ref} -t ghcr.io/${USERNAME}/remark24-site:latest