mirror of
https://github.com/FoxxMD/multi-scrobbler.git
synced 2026-05-10 12:19:24 +00:00
ci: Refactor ACT for more thorough usage
* All required files in the same file by using .actrc * Include example .secrets and .env * Update README with usage * Refactor actTest to make docker build steps optional with ENV
This commit is contained in:
parent
005dae76ab
commit
5b8a8a7449
9 changed files with 79 additions and 56 deletions
3
.github/act/.actrc
vendored
Normal file
3
.github/act/.actrc
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
--directory ../../
|
||||
--env-file .github/act/.env
|
||||
--secret-file .github/act/.secrets
|
||||
1
.github/act/.env.example
vendored
Normal file
1
.github/act/.env.example
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
NO_DOCKER_BUILD=true
|
||||
3
.github/act/.secrets.example
vendored
Normal file
3
.github/act/.secrets.example
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
DOCKER_PASSWORD=
|
||||
DOCKER_USERNAME=
|
||||
GITHUB_TOKEN=
|
||||
15
.github/act/README.md
vendored
15
.github/act/README.md
vendored
|
|
@ -1,5 +1,11 @@
|
|||
Testing GH Actions with [ACT]
|
||||
|
||||
Need to have credentials in a [`.secrets` file](https://nektosact.com/usage/index.html#secrets), copy and rename [`.secrets.example`](./secrets.example) to `.secrets`, then fill out blank fields. Required for docker/metadata-action to read...something. Fails with `Parameter token or opts.auth is required` if they are not supplied.
|
||||
|
||||
An ENV file can also be made by copy and renaming [`.env.example`](./env.example). Set `NO_DOCKER_BUILD=true` if you only want to test APP_VERSION and docker tags output.
|
||||
|
||||
Run the following **from this directory** to make use of `.actrc` and proper working directoy.
|
||||
|
||||
### Test Branch Push
|
||||
|
||||
```shell
|
||||
|
|
@ -7,8 +13,15 @@ act -W '.github/act/actTest.yml' -e '.github/act/actBranchEvent.json'
|
|||
```
|
||||
|
||||
|
||||
### Test Tag Push
|
||||
### Test Tag (Release) Push
|
||||
|
||||
```shell
|
||||
act -W '.github/act/actTest.yml' -e '.github/act/actTagEvent.json'
|
||||
```
|
||||
|
||||
|
||||
### Test Tag (Pre-Release) Push
|
||||
|
||||
```shell
|
||||
act -W '.github/act/actTest.yml' -e '.github/act/actTagPreEvent.json'
|
||||
```
|
||||
|
|
|
|||
2
.github/act/actBranchEvent.json
vendored
2
.github/act/actBranchEvent.json
vendored
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"ref": "refs/heads/master",
|
||||
"sha": "e80ad81f051e2ff29e73c0401ad9b89a1b32c3f7"
|
||||
"sha": "005dae76ab51799d3d55112738e301cb1af0dafd"
|
||||
}
|
||||
|
|
|
|||
9
.github/act/actTagEvent.json
vendored
9
.github/act/actTagEvent.json
vendored
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"ref": "refs/tags/0.8.0",
|
||||
"ref_name": "0.8.0",
|
||||
"sha": "0a1a94d9ad4efa373f8d34aace5e7f0a3fff42ad"
|
||||
"ref": "refs/tags/0.8.4",
|
||||
"ref_name": "0.8.4",
|
||||
"before": "0000000000000000000000000000000000000000",
|
||||
"after": "005dae76ab51799d3d55112738e301cb1af0dafd",
|
||||
"sha": "005dae76ab51799d3d55112738e301cb1af0dafd",
|
||||
"base_ref": "refs/heads/master"
|
||||
}
|
||||
|
|
|
|||
8
.github/act/actTagPreEvent.json
vendored
Normal file
8
.github/act/actTagPreEvent.json
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"ref": "refs/tags/0.8.5-rc1",
|
||||
"ref_name": "0.8.5-rc1",
|
||||
"before": "0000000000000000000000000000000000000000",
|
||||
"after": "005dae76ab51799d3d55112738e301cb1af0dafd",
|
||||
"sha": "005dae76ab51799d3d55112738e301cb1af0dafd",
|
||||
"base_ref": "refs/heads/master"
|
||||
}
|
||||
68
.github/act/actTest.yml
vendored
68
.github/act/actTest.yml
vendored
|
|
@ -1,6 +1,7 @@
|
|||
name: Publish Docker image to Dockerhub
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
|
|
@ -8,7 +9,9 @@ on:
|
|||
- '*.*.*'
|
||||
# don't trigger if just updating docs
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'README.md'
|
||||
- '.github/**'
|
||||
- 'flatpak/**'
|
||||
# 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
|
||||
|
|
@ -17,16 +20,10 @@ on:
|
|||
|
||||
jobs:
|
||||
|
||||
test:
|
||||
push_to_registry:
|
||||
name: Build and push container images
|
||||
if: github.event_name != 'pull_request'
|
||||
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
|
||||
|
|
@ -46,11 +43,6 @@ jobs:
|
|||
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
|
||||
|
|
@ -62,26 +54,38 @@ jobs:
|
|||
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: 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=edge
|
||||
|
||||
# maybe re-enable branch-named tags in the futures
|
||||
#type=ref,event=branch,enable=${{ !endsWith(github.ref, 'master') }}
|
||||
|
||||
# tag non-prelease as latest -- has a higher priority than regular tag so it shows first in registries
|
||||
type=match,pattern=\d.\d.\d$,priority=901
|
||||
|
||||
# tag all semver (include pre-release)
|
||||
type=semver,pattern={{version}}
|
||||
# flavor: |
|
||||
# latest=false
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
id: qemu
|
||||
if: ${{ !env.NO_DOCKER_BUILD }}
|
||||
|
||||
# - name: Set up Docker Buildx
|
||||
# uses: docker/setup-buildx-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
if: ${{ steps.qemu.outcome == 'success' }}
|
||||
continue-on-error: true
|
||||
|
||||
- name: Build and push Docker image
|
||||
if: ${{ steps.qemu.outcome == 'success' }}
|
||||
env:
|
||||
# use release instead of tags once version is correctly parsed
|
||||
#APP_VERSION: ${{ github.event.release.tag_name }}
|
||||
|
|
@ -95,9 +99,7 @@ jobs:
|
|||
# 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 }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
|
|
|
|||
26
.github/workflows/publishImage.yml
vendored
26
.github/workflows/publishImage.yml
vendored
|
|
@ -43,16 +43,6 @@ jobs:
|
|||
if: github.event_name != 'pull_request'
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- dockerfile: ./Dockerfile
|
||||
suffix: ''
|
||||
platforms: 'linux/amd64,linux/arm64'
|
||||
# - dockerfile: ./alpine.Dockerfile
|
||||
# suffix: '-alpine'
|
||||
# platforms: 'linux/amd64,linux/arm64'
|
||||
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
|
||||
permissions:
|
||||
packages: write
|
||||
|
|
@ -95,16 +85,17 @@ jobs:
|
|||
# https://github.com/docker/metadata-action/issues/247#issuecomment-1511259674 for NOT is default branch, eventually
|
||||
tags: |
|
||||
type=edge
|
||||
type=ref,event=branch,enable=${{ !endsWith(github.ref, 'master') }}
|
||||
|
||||
# maybe re-enable branch-named tags in the futures
|
||||
#type=ref,event=branch,enable=${{ !endsWith(github.ref, 'master') }}
|
||||
|
||||
# tag non-prelease as latest -- has a higher priority than regular tag so it shows first in registries
|
||||
type=semver,pattern={{major}}.{{minor}}.{{patch}},value=latest,priority=901
|
||||
type=match,pattern=\d.\d.\d$,priority=901
|
||||
|
||||
# tag all semver (include pre-release)
|
||||
type=semver,pattern={{version}}
|
||||
flavor: |
|
||||
latest=false
|
||||
# suffix=${{ matrix.suffix }},onlatest=false
|
||||
# flavor: |
|
||||
# latest=false
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
|
@ -126,8 +117,7 @@ jobs:
|
|||
# https://github.com/docker/build-push-action/issues/1026#issue-2041857786
|
||||
build-args: |
|
||||
APP_BUILD_VERSION=${{env.APP_VERSION}}
|
||||
file: ${{ matrix.dockerfile }}
|
||||
push: ${{ !env.ACT}}
|
||||
push: ${{ !env.ACT }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: ${{ matrix.platforms }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue