Set serve from subpath to false #186
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
name: Build | |
on: | |
push: | |
branches: [ main, 'develop/**' ] | |
jobs: | |
matrix: # sets the matrix | |
runs-on: ubuntu-latest | |
outputs: | |
plugin: ${{ steps.matrix.outputs.plugin }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v44 | |
with: | |
dir_names: "true" | |
since_last_remote_commit: true | |
files_ignore: | | |
**/*.md | |
**/**.md | |
**/assets/** | |
**/docs/** | |
.github/** | |
Dockerfile | |
Makefile | |
- name: Set the plugins matrix | |
id: matrix | |
run: | | |
directories=$(echo ${{ steps.changed-files.outputs.all_changed_and_modified_files }} | awk '{for (i=1; i<=NF; i++) {sub(/\/.*/, "", $i); printf "%s ", $i}}' | xargs -n1 | sort -u) # get main directory and remove duplicate directories | |
matrix=$(( | |
echo '{ "plugin" : [' | |
separator='' | |
for d in $directories; do | |
[[ $d != "." ]] || continue; | |
[[ $d != ".github"* ]] || continue; | |
[[ $d != *"/"* ]] || continue; | |
[[ $d != "_"* ]] || continue; | |
[[ $d != *".md" ]] || continue; | |
[[ $d != *"/assets/"* ]] || continue; | |
echo -n "$separator"\""$d"\"; separator=','; | |
done | |
echo "]}" | |
) | jq -c .) | |
# if branch is develop/<plugin> keep in matrix only the plugin if it exists | |
branch=${GITHUB_REF#refs/heads/} | |
if [[ "$branch" == "develop/"* ]]; then | |
plugins=${branch#develop/} | |
if echo "$matrix" | jq -e --arg value "$plugins" '.plugin | index($value)' > /dev/null; then | |
matrix='{"plugin":["'$plugins'"]}' | |
else | |
matrix='{"plugin":[]}' | |
fi | |
fi | |
echo "plugin=$matrix" >> $GITHUB_OUTPUT | |
- name: Check content of matrix | |
run: echo ${{ steps.matrix.outputs.plugin }} | |
build: | |
if: ${{ needs.matrix.outputs.plugin != '{"plugin":[]}' }} # check if matrix is not empty | |
runs-on: ubuntu-latest | |
needs: matrix | |
strategy: | |
fail-fast: false # continues with matrix even if an element fails | |
matrix: ${{fromJson(needs.matrix.outputs.plugin)}} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Extract branch name | |
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | |
- name: Get image version | |
run: | | |
if [[ "${{ env.branch }}" == "main" ]]; then | |
echo docker_version=`jq '.version' ./${{ matrix.plugin }}/plugin.json | tr -d \"` >> $GITHUB_ENV | |
echo version=v`jq '.version' ./${{ matrix.plugin }}/plugin.json | tr -d \"` >> $GITHUB_ENV | |
else | |
echo docker_version=develop >> $GITHUB_ENV | |
echo version=develop >> $GITHUB_ENV | |
fi | |
echo plugin_file=`cat ./${{ matrix.plugin }}/plugin.json` >> $GITHUB_ENV | |
- name: Check if Dockerfile exists | |
id: check_dockerfile | |
uses: andstor/file-existence-action@v3 | |
with: | |
files: "${{ matrix.plugin }}/task/Dockerfile" | |
- name: Set up QEMU | |
if: ${{ steps.check_dockerfile.outputs.files_exists == 'true' }} | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
if: ${{ steps.check_dockerfile.outputs.files_exists == 'true' }} | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
if: ${{ steps.check_dockerfile.outputs.files_exists == 'true' }} | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub container Registry | |
if: ${{ steps.check_dockerfile.outputs.files_exists == 'true' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
if: ${{ steps.check_dockerfile.outputs.files_exists == 'true' }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: ${{ matrix.plugin }}/task | |
push: true | |
tags: | | |
thinger/${{ matrix.plugin }}-plugin:${{ env.docker_version }} | |
- name: Update README in DockerHub | |
if: ${{ steps.check_dockerfile.outputs.files_exists == 'true' && env.branch == 'main' }} | |
uses: peter-evans/dockerhub-description@v4 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
repository: thinger/${{ matrix.plugin }}-plugin | |
readme-filepath: ./${{ matrix.plugin }}/README.md | |
- name: Delete tag of repository | |
if: ${{ startsWith(env.branch, 'develop') }} | |
uses: dev-drprasad/[email protected] | |
with: | |
tag_name: ${{ matrix.plugin }}/${{ env.version }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
delete_release: false | |
- name: Tag repository | |
uses: mathieudutour/[email protected] | |
continue-on-error: true | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
custom_tag: ${{ matrix.plugin }}/${{ env.version }} | |
tag_prefix: '' | |
- name: Post tag to DB | |
uses: fjogeleit/http-request-action@v1 | |
with: | |
url: "https://cloud.thinger.io/plugins/${{ matrix.plugin }}/tags/${{ env.version }}" | |
method: 'PUT' | |
username: ${{ secrets.LAMBDA_USER }} | |
password: ${{ secrets.LAMBDA_PASSWORD }} | |
timeout: 30000 # 30s | |
customHeaders: '{"Content-Type": "application/json"}' | |
data: | | |
{ | |
"plugin": "${{ matrix.plugin }}", | |
"version": "${{ env.version }}", | |
"commit": "${{ github.sha }}", | |
"repository": "${{ github.repository }}", | |
"server_url": "${{ github.server_url }}", | |
"plugin_file": ${{ env.plugin_file }} | |
} |