From 8c57a7bb2839400790bd19bcf720c4e9771aa23e Mon Sep 17 00:00:00 2001 From: marcobaobao Date: Wed, 2 Aug 2023 14:47:38 +0200 Subject: [PATCH] github actions rewrite --- .github/workflows/backend.yml | 23 ++++++++++++++++++++++ .github/workflows/docker-image.yml | 28 --------------------------- .github/workflows/docker-publish.yml | 29 ++++++++++++++++++++-------- .github/workflows/frontend.yml | 24 +++++++++++++++++++++++ 4 files changed, 68 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/backend.yml delete mode 100644 .github/workflows/docker-image.yml create mode 100644 .github/workflows/frontend.yml diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml new file mode 100644 index 0000000..84ce3e0 --- /dev/null +++ b/.github/workflows/backend.yml @@ -0,0 +1,23 @@ +name: Go + +on: + pull_request: + branches: [ "master" ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml deleted file mode 100644 index f2f86ce..0000000 --- a/.github/workflows/docker-image.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Docker Image CI (Dockerhub) - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - schedule: - - cron: '0 1 * * *' - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Login to Docker Hub - env: - DOCKER_USER: ${{secrets.DOCKER_HUB_USERNAME}} - DOCKER_PASSWORD: ${{secrets.DOCKER_HUB_PASSWORD}} - run: | - docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - - name: Install buildx - uses: crazy-max/ghaction-docker-buildx@v1 - with: - version: latest - - name: Build the Docker image - run: docker buildx build . --file Dockerfile --tag ${{secrets.DOCKER_HUB_USERNAME}}/yt-dlp-webui:latest --push --platform linux/amd64,linux/arm/v7,linux/arm64 - diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index a484406..b726256 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -7,12 +7,9 @@ name: Docker (ghcr.io) on: release: - branches: [ master ] - tags: [ 'v*.*.*' ] + types: [published] push: branches: [ master ] - pull_request: - branches: [ master ] schedule: - cron : '0 1 * * 0' @@ -24,8 +21,7 @@ env: jobs: - build: - + build-ghcr: runs-on: ubuntu-latest permissions: contents: read @@ -33,7 +29,6 @@ jobs: # This is used to complete the identity challenge # with sigstore/fulcio when running outside of PRs. id-token: write - steps: - name: Checkout repository uses: actions/checkout@v2 @@ -46,7 +41,6 @@ jobs: with: cosign-release: 'v1.13.1' - # Workaround: https://github.com/docker/build-push-action/issues/461 - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -95,3 +89,22 @@ jobs: # This step uses the identity token to provision an ephemeral certificate # against the sigstore community Fulcio instance. run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push.outputs.digest }} + + build-dockerhub: + runs-on: ubuntu-latest + env: + REGISTRY: 'docker.io' + steps: + - uses: actions/checkout@v2 + - name: Login to Docker Hub + env: + DOCKER_USER: ${{secrets.DOCKER_HUB_USERNAME}} + DOCKER_PASSWORD: ${{secrets.DOCKER_HUB_PASSWORD}} + run: | + docker login -u $DOCKER_USER -p $DOCKER_PASSWORD + - name: Install buildx + uses: crazy-max/ghaction-docker-buildx@v1 + with: + version: latest + - name: Build the Docker image + run: docker buildx build . --file Dockerfile --tag ${{secrets.DOCKER_HUB_USERNAME}}/yt-dlp-webui:latest --push --platform linux/amd64,linux/arm/v7,linux/arm64 \ No newline at end of file diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml new file mode 100644 index 0000000..06480d3 --- /dev/null +++ b/.github/workflows/frontend.yml @@ -0,0 +1,24 @@ +name: Node.js CI + +on: + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build --if-present