-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
89 changed files
with
3,909 additions
and
5,098 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
node_modules | ||
npm-debug.log | ||
Dockerfile | ||
*.Dockerfile | ||
.dockerignore | ||
.gitignore | ||
.github | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Testing GH Actions with [ACT] | ||
|
||
### Test Branch Push | ||
|
||
```shell | ||
act -W '.github/act/actTest.yml' -e '.github/act/actBranchEvent.json' | ||
``` | ||
|
||
|
||
### Test Tag Push | ||
|
||
```shell | ||
act -W '.github/act/actTest.yml' -e '.github/act/actTagEvent.json' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"ref": "refs/heads/master", | ||
"sha": "0a1a94d9ad4efa373f8d34aace5e7f0a3fff42ad" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"ref": "refs/tags/0.8.0", | ||
"ref_name": "0.8.0", | ||
"sha": "0a1a94d9ad4efa373f8d34aace5e7f0a3fff42ad" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
name: Publish Docker image to Dockerhub | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
- 'develop' | ||
tags: | ||
- '*.*.*' | ||
# don't trigger if just updating docs | ||
paths-ignore: | ||
- '**.md' | ||
# use release instead of tags once version is correctly parsed | ||
# https://github.com/docker/metadata-action/issues/422 | ||
# https://github.com/docker/metadata-action/issues/240 | ||
# release: | ||
# types: [ published ] | ||
|
||
jobs: | ||
|
||
test: | ||
name: Build and push container images | ||
runs-on: ubuntu-latest | ||
# strategy: | ||
# fail-fast: false | ||
# matrix: | ||
# include: | ||
# - dockerfile: ./Dockerfile | ||
# suffix: '' | ||
# platforms: 'linux/amd64' | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Debug | ||
run: echo $JSON | ||
env: | ||
JSON: ${{ toJSON(github) }} | ||
|
||
- name: Set git state to ENV | ||
id: vars | ||
# https://dev.to/hectorleiva/github-actions-and-creating-a-short-sha-hash-8b7 | ||
# short sha available under env.COMMIT_SHORT_SHA | ||
run: | | ||
calculatedSha=$(git rev-parse --short HEAD) | ||
branchName=$(git rev-parse --abbrev-ref HEAD) | ||
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV | ||
echo "COMMIT_BRANCH=$branchName" >> $GITHUB_ENV | ||
# - name: Set push event short ref | ||
# run: | | ||
# shortEventRef=${github.event.push.ref:10} | ||
# echo "SHORT_REF=$shortEventRef" >> $GITHUB_ENV | ||
|
||
- name: Check App Version | ||
env: | ||
# use release instead of tags once version is correctly parsed | ||
#APP_VERSION: ${{ github.event.release.tag_name }} | ||
|
||
# https://github.com/actions/runner/issues/409#issuecomment-752775072 | ||
# https://stackoverflow.com/a/69919067/1469797 | ||
APP_VERSION: ${{ contains(github.ref, 'refs/tags/') && github.ref_name || format('{0}-{1}', env.COMMIT_BRANCH, env.COMMIT_SHORT_SHA ) }} | ||
run: | | ||
echo $APP_VERSION | ||
# - name: Extract metadata (tags, labels) for Docker | ||
# id: meta | ||
# uses: docker/metadata-action@v5 | ||
# with: | ||
# # generate Docker tags based on the following events/attributes | ||
# # https://github.com/docker/metadata-action/issues/247#issuecomment-1511259674 for NOT is default branch, eventually | ||
# tags: | | ||
# type=raw,value=latest,enable={{endsWith(github.ref, 'master')}},suffix=${{ matrix.suffix }} | ||
# type=ref,event=branch,enable=${{ !endsWith(github.ref, 'master') }},suffix=${{ matrix.suffix }} | ||
# type=semver,pattern={{version}},suffix=${{ matrix.suffix }} | ||
# flavor: | | ||
# latest=false | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
# - name: Set up Docker Buildx | ||
# uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build and push Docker image | ||
env: | ||
# use release instead of tags once version is correctly parsed | ||
#APP_VERSION: ${{ github.event.release.tag_name }} | ||
|
||
# https://github.com/actions/runner/issues/409#issuecomment-752775072 | ||
# https://stackoverflow.com/a/69919067/1469797 | ||
APP_VERSION: ${{ contains(github.ref, 'refs/tags/') && github.ref_name || format('{0}-{1}', env.COMMIT_BRANCH, env.COMMIT_SHORT_SHA ) }} | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
# https://github.com/docker/build-push-action/issues/1026#issue-2041857786 | ||
build-args: | | ||
APP_BUILD_VERSION=${{env.APP_VERSION}} | ||
file: ${{ matrix.dockerfile }} | ||
push: false | ||
tags: mstest:latest | ||
#tags: ${{ steps.meta.outputs.tags }} | ||
#labels: ${{ steps.meta.outputs.labels }} | ||
#platforms: ${{ matrix.platforms }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Delete Untagged Packages | ||
on: | ||
schedule: | ||
- cron: '30 1 * * *' | ||
workflow_run: | ||
workflows: ["Publish Docker image to Dockerhub"] | ||
types: | ||
- completed | ||
workflow_dispatch: | ||
jobs: | ||
delete-untagged: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
steps: | ||
- uses: dataaxiom/ghcr-cleanup-action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# maybe set up for PR close later | ||
# https://github.com/dataaxiom/ghcr-cleanup-action?tab=readme-ov-file#delete-image-when-pull-request-is-closed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
name: PR Workflow | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- labeled | ||
- synchronize | ||
- reopened | ||
- opened | ||
branches: | ||
- 'develop' | ||
|
||
jobs: | ||
test: | ||
name: Run Tests | ||
runs-on: ubuntu-latest | ||
if: contains(github.event.pull_request.labels.*.name, 'safe to test') | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18.x' | ||
cache: 'npm' | ||
- name: Install dev dependencies | ||
run: npm ci | ||
- name: Build Backend | ||
run: 'npm run build:backend' | ||
- name: Test Backend | ||
run: npm run test | ||
|
||
release-snapshot: | ||
name: Release snapshot | ||
runs-on: ubuntu-latest | ||
needs: test | ||
if: contains(github.event.pull_request.labels.*.name, 'safe to test') | ||
permissions: | ||
packages: write | ||
contents: read | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- dockerfile: ./Dockerfile | ||
suffix: '' | ||
platforms: 'linux/amd64,linux/arm64' | ||
- dockerfile: ./alpine.Dockerfile | ||
suffix: '-alpine' | ||
platforms: 'linux/amd64,linux/arm64' | ||
steps: | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
foxxmd/multi-scrobbler | ||
ghcr.io/foxxmd/multi-scrobbler | ||
tags: | | ||
type=ref,event=pr,suffix=${{ matrix.suffix }} | ||
flavor: | | ||
latest=false | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v5 | ||
env: | ||
APP_VERSION: ${{ format('pr{0}-{1}', github.event.number, github.event.pull_request.head.sha ) }} | ||
with: | ||
context: . | ||
build-args: | | ||
APP_BUILD_VERSION=${{env.APP_VERSION}} | ||
file: ${{ matrix.dockerfile }} | ||
push: ${{ !env.ACT}} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
platforms: ${{ matrix.platforms }} | ||
|
||
combine-and-comment: | ||
name: Leave comment | ||
runs-on: ubuntu-latest | ||
needs: release-snapshot | ||
if: contains(github.event.pull_request.labels.*.name, 'safe to test') | ||
steps: | ||
- name: Create comment | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
recreate: true | ||
header: "pr-release" | ||
message: | | ||
#### :package: A new release has been made for this pull request. | ||
To play around with this PR, pull an image: | ||
* `foxxmd/multi-scrobbler:pr-${{ github.event.number }}` | ||
* `foxxmd/multi-scrobbler:pr-${{ github.event.number }}-alpine`. | ||
Images are available for x86_64 and ARM64. | ||
> Latest commit: ${{ github.event.pull_request.head.sha }} |
Oops, something went wrong.