From 5bd90eea8f7bf60122d5ef80eabab9a6eb4f18d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9andre=20Daumont?= <1338620+digiz3d@users.noreply.github.com> Date: Wed, 17 May 2023 23:30:01 +0200 Subject: [PATCH 1/3] chore: setup ci first attempt --- .github/workflows/ci.yml | 39 ++++++++++++++++++++++++++++++++++++ .github/workflows/docker.yml | 26 ++++++++++++++++++++++++ README.md | 2 +- package.json | 1 + 4 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e7b9155 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: ci +on: + push: + branches: + - main +jobs: + release-please: + runs-on: ubuntu-latest + outputs: + releases_created: ${{ steps.release-please.outputs.releases_created }} + steps: + - uses: google-github-actions/release-please-action@v3 + id: release-please + with: + release-type: node + package-name: docker-web-recorder + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + get-release: + needs: release-please + if: ${{ needs.release-please.outputs.releases_created }} + runs-on: ubuntu-latest + outputs: + release_id: ${{ steps.get-last-release.outputs.result }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + - name: get version + run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV + - id: get-last-release + name: Get last release + uses: actions/github-script@v6 + with: + script: | + const { data } = await github.rest.repos.getReleaseByTag({ + owner: context.repo.owner, + repo: context.repo.repo, + tag: `v${process.env.PACKAGE_VERSION}` + }) + return data.id diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..f93ad81 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,26 @@ +name: docker +on: + push: + branches: + - chore/setup-ci +jobs: + build-docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + - name: get version + id: get_version + run: echo "package_version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT + - uses: docker/setup-qemu-action@v2 + - uses: docker/setup-buildx-action@v2 + - uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: leandredaumont/docker-web-recorder:latest,leandredaumont/docker-web-recorder:${{steps.get_version.outputs.package_version}} diff --git a/README.md b/README.md index 8cce422..c4a413e 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ docker build -t docker-web-recorder:latest . ## Record a file ```bash -docker run -v /absolute/path/to/your/recordings:/app/recordings --rm -e OUTPUT=video.mp4 -e URL=https://xxxxx.com/video/123456 -e DURATION=25 -it docker-web-recorder:latest +docker run --rm -v /absolute/path/to/your/recordings:/app/recordings -e OUTPUT=video.mp4 -e URL=https://xxxxx.com/video/123456 -e DURATION=25 -it docker-web-recorder:latest ``` ## Make a livestream diff --git a/package.json b/package.json index 6accb60..b3990a3 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "docker-web-recorder", + "private": true, "version": "0.0.1", "description": "Docker container that can record web pages with sound", "main": "src/index.ts", From 779155a8f6e6e972678bdd52b53e2273df69f629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9andre=20Daumont?= <1338620+digiz3d@users.noreply.github.com> Date: Wed, 17 May 2023 23:39:39 +0200 Subject: [PATCH 2/3] chore: only publish new docker on release --- .github/workflows/ci.yml | 24 +++++++++++++++++++++++- .github/workflows/docker.yml | 26 -------------------------- 2 files changed, 23 insertions(+), 27 deletions(-) delete mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7b9155..32eb2d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: ci +name: Release and publish on: push: branches: @@ -37,3 +37,25 @@ jobs: tag: `v${process.env.PACKAGE_VERSION}` }) return data.id + publish-docker: + needs: get-release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + - name: get version + id: get_version + run: echo "package_version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT + - uses: docker/setup-qemu-action@v2 + - uses: docker/setup-buildx-action@v2 + - uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: leandredaumont/docker-web-recorder:latest,leandredaumont/docker-web-recorder:${{steps.get_version.outputs.package_version}} + diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index f93ad81..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: docker -on: - push: - branches: - - chore/setup-ci -jobs: - build-docker: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - - name: get version - id: get_version - run: echo "package_version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT - - uses: docker/setup-qemu-action@v2 - - uses: docker/setup-buildx-action@v2 - - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - uses: docker/build-push-action@v4 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: true - tags: leandredaumont/docker-web-recorder:latest,leandredaumont/docker-web-recorder:${{steps.get_version.outputs.package_version}} From 8178daf16c5e44c8061d8964843430c016a8fd8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9andre=20Daumont?= <1338620+digiz3d@users.noreply.github.com> Date: Wed, 17 May 2023 23:39:58 +0200 Subject: [PATCH 3/3] remove useless empty line --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32eb2d4..58e697c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,4 +58,3 @@ jobs: platforms: linux/amd64,linux/arm64 push: true tags: leandredaumont/docker-web-recorder:latest,leandredaumont/docker-web-recorder:${{steps.get_version.outputs.package_version}} -