2020-11-13 22:15:01 +08:00
|
|
|
on: [push]
|
2019-08-17 18:04:35 +08:00
|
|
|
name: Deploy workflow
|
|
|
|
jobs:
|
|
|
|
install:
|
2020-11-13 22:15:01 +08:00
|
|
|
runs-on: ubuntu-20.04
|
2019-08-17 18:04:35 +08:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2020-11-13 22:15:01 +08:00
|
|
|
node-version: [14.x]
|
2019-08-17 18:04:35 +08:00
|
|
|
|
|
|
|
steps:
|
2020-03-05 09:53:41 +08:00
|
|
|
- uses: actions/checkout@v2
|
2019-08-17 18:04:35 +08:00
|
|
|
|
2019-11-09 14:52:28 +08:00
|
|
|
- name: Use Node.js ${{ matrix.node-version }}
|
2020-11-13 23:33:14 +08:00
|
|
|
uses: actions/setup-node@v2.1.2
|
2019-11-09 14:52:28 +08:00
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node-version }}
|
2019-08-17 18:04:35 +08:00
|
|
|
|
2020-11-13 23:33:14 +08:00
|
|
|
- name: Get yarn cache directory path
|
|
|
|
id: yarn-cache-dir-path
|
|
|
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
|
|
- uses: actions/cache@v2
|
|
|
|
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
2019-11-14 00:31:03 +08:00
|
|
|
with:
|
2020-11-13 23:33:14 +08:00
|
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
2019-11-14 00:31:03 +08:00
|
|
|
restore-keys: |
|
2020-11-13 23:33:14 +08:00
|
|
|
${{ runner.os }}-yarn-
|
2019-11-14 00:31:03 +08:00
|
|
|
|
2020-11-13 23:33:14 +08:00
|
|
|
- name: Install
|
|
|
|
run: yarn
|
|
|
|
- name: Lint
|
|
|
|
run: yarn lint
|
|
|
|
- name: Build
|
|
|
|
run: yarn build
|
2019-08-17 18:04:35 +08:00
|
|
|
|
2020-11-24 11:22:53 +08:00
|
|
|
- name: Create Release
|
|
|
|
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
|
|
|
|
id: create_release
|
|
|
|
uses: actions/create-release@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
tag_name: ${{ github.ref }}
|
|
|
|
release_name: ${{ github.ref }}
|
|
|
|
draft: true
|
|
|
|
prerelease: false
|
|
|
|
- name: Create Tar Ball
|
|
|
|
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
|
2020-11-24 19:43:14 +08:00
|
|
|
run: tar cJf yacd.tar.xz public
|
2020-11-24 11:22:53 +08:00
|
|
|
- name: Upload Release Asset
|
|
|
|
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
|
|
|
|
id: upload-release-asset
|
|
|
|
uses: actions/upload-release-asset@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
|
|
asset_path: ./yacd.tar.xz
|
|
|
|
asset_name: yacd.tar.xz
|
|
|
|
asset_content_type: application/x-gzip
|
|
|
|
|
2019-11-09 14:52:28 +08:00
|
|
|
- name: Push to gh-pages
|
2020-11-13 22:15:01 +08:00
|
|
|
if: github.event_name == 'push' && (startsWith(github.event.ref, 'refs/tags/') || github.event.ref == 'refs/heads/publish')
|
2019-11-09 14:52:28 +08:00
|
|
|
env:
|
2019-11-17 17:56:32 +08:00
|
|
|
GITHUB_TOKEN: ${{ secrets.TOKEN }}
|
2019-11-09 14:52:28 +08:00
|
|
|
PUBLISH_DIR: public
|
|
|
|
BRANCH: gh-pages
|
|
|
|
run: |
|
|
|
|
cd $PUBLISH_DIR
|
|
|
|
ls -l
|
|
|
|
git init
|
|
|
|
git config user.name "${GITHUB_ACTOR}"
|
|
|
|
git config user.email "${GITHUB_ACTOR}@noreply.github.com"
|
|
|
|
git add .
|
|
|
|
git status
|
|
|
|
git commit -m "Push to gh-pages"
|
|
|
|
git push -f https://$GITHUB_ACTOR:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:$BRANCH
|
2020-08-01 20:49:00 +08:00
|
|
|
|
|
|
|
- name: Send Notification
|
|
|
|
uses: haishanh/actions-telegram-notification@v1
|
2020-10-12 20:51:13 +08:00
|
|
|
if: ${{ always() }}
|
2020-08-01 20:49:00 +08:00
|
|
|
with:
|
|
|
|
notification-token: ${{ secrets.TG_NOTIFICATION_TOKEN }}
|
|
|
|
job-status: ${{ job.status }}
|
2020-11-13 22:15:01 +08:00
|
|
|
|
|
|
|
docker:
|
|
|
|
needs: install
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2020-11-14 14:57:49 +08:00
|
|
|
|
|
|
|
- name: Docker meta
|
|
|
|
id: docker_meta
|
|
|
|
uses: crazy-max/ghaction-docker-meta@v1
|
|
|
|
with:
|
|
|
|
images: haishanh/yacd
|
|
|
|
|
2020-11-13 22:15:01 +08:00
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
2020-11-14 14:57:49 +08:00
|
|
|
|
2020-11-13 22:15:01 +08:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
id: buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
with:
|
|
|
|
version: latest
|
2020-11-14 14:57:49 +08:00
|
|
|
|
2020-11-13 22:15:01 +08:00
|
|
|
- name: Builder instance name
|
|
|
|
run: echo ${{ steps.buildx.outputs.name }}
|
|
|
|
- name: Available platforms
|
|
|
|
run: echo ${{ steps.buildx.outputs.platforms }}
|
2020-11-14 14:57:49 +08:00
|
|
|
|
|
|
|
- name: Login to Docker Hub
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
|
|
|
|
|
|
|
- name: Build and push
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: ./Dockerfile
|
|
|
|
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
|
|
|
push: true
|
|
|
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
|
|
|
|
2020-11-13 22:15:01 +08:00
|
|
|
- name: Send Notification
|
|
|
|
uses: haishanh/actions-telegram-notification@v1
|
|
|
|
if: ${{ always() }}
|
|
|
|
with:
|
|
|
|
notification-token: ${{ secrets.TG_NOTIFICATION_TOKEN }}
|
|
|
|
job-status: ${{ job.status }}
|