diff --git a/README.md b/README.md index 1b631be..facf1e8 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,15 @@ |name|default|note| |:---:|:---:|:---:| -|token-git|-|master token used for git operations. not required. will be used as a fallback if any of the other two tokens is left unspecified| |build-image|git.dzuchun.ing/actions/anode-builder:latest|image the build process will undergo on. you may want to override it with your own image, if you use static libraries not installed on the default image| |src-repository|-|git repository to clone action's Rust source from| -|src-ref|master|ref of the source repository to use| +|src-ref|(whatever the default branch is)|ref of the source repository to use| |src-actor|actions|actor for cloning the action source| -|src-token|(token input)|a git token to used to perform a git clone of the action source. not required; action may fail of the git server refuses the operation| +|src-token|-|a git token to used to perform a git clone of the action source. not required; action may fail of the git server refuses the operation| |dst-repository|-|git repository to push the compiled action to| -|dst-ref|master|ref of the repository to push the compiled action to.| +|dst-ref|(whatever the default branch is)|ref of the repository to push the compiled action to.| |dst-actor|actions|actor pushing the compiled action| -|dst-token|(token input)|a git token to used to perform the git push of the compiled action to the destination repository. not required. git server is very likely to refuse the push if you leave this blank| +|dst-token|-|a git token to used to perform the git push of the compiled action to the destination repository. not required. git server is very likely to refuse the push if you leave this blank| |opt-release|false|use release profile| |opt-build-std|false|use nightly toolchain with build-std feature| |opt-upx|false|use UPX to compress the binary even further. please note that this subjects you to UPX's terms of use.| diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..e73b4f8 --- /dev/null +++ b/action.yml @@ -0,0 +1,45 @@ +name: 'Build anode action' +description: 'Checkout, build and update the anode action' +inputs: + build-image: + description: 'OCI image to use for building the action' + default: git.dzuchun.ing/actions/anode-builder:master + required: false + src-repository: + description: 'Git repository to clone the the action source from' + required: true + src-ref: + description: 'Git tag to clone the action source from' + required: false + src-actor: + description: 'Git use to clone the action source as' + default: actions + src-token: + description: 'Git token to use for cloning the action source' + required: false + dst-repository: + description: 'Git repository to upload the compiled actio to' + required: true + dst-ref: + description: 'Git branch to upload the compiled action to' + required: false + dst-actor: + description: 'Git user to upload the action as' + default: actions + dst-token: + description: 'Git token to use whiee uploading the action' + required: false + opt-release: + description: 'Use Rust release profile while compiling the action' + default: false + opt-build-std: + description: 'Use nightly Rust toolchain, and `build-std` feature' + default: false + opt-upx: + description: 'Compress the resulting biinary this UPX' + default: false +runs: + using: composite + steps: + - run: ${{ forgejo.action_path }}/main.sh + shell: bash diff --git a/main.sh b/main.sh new file mode 100755 index 0000000..b8db8ef --- /dev/null +++ b/main.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -eu + +BUILDER_IMAGE=$(printenv INPUT-BUILD-IMAGE) + +SRC_REPOSITORY=$(printenv INPUT-SRC-REPOSITORY) +SRC_REF=$(printenv INPUT-SRC-REF:-master) +SRC_ACTOR=$(printenv INPUT-SRC-REF:-actions) +SRC_TOKEN=$(printenv INPUT-SRC-TOKEN) + +DST_REPOSITORY=$(printenv INPUT-DST-REPOSITORY) +DST_REF=$(printenv INPUT-DST-REF:-master) +DST_ACTOR=$(printenv INPUT-DST-REF:-actions) +DST_TOKEN=$(printenv INPUT-DST-TOKEN) + +OPT_RELEASE=$(printenv INPUT-OPT-RELEASE:-false) +OPT_BUILD_STD=$(printenv INPUT-OPT-BUILD-STD:-false) +OPT_UPX=$(printenv INPUT-OPT-UPX:-false) + +GIT_FPUSH=$(printenv INPUT-GIT-FPUSH:-false) + +echo "SRC_REPOSITORY=$SRC_REPOSITORY" > .env +echo "SRC_REF=$SRC_REF" >> .env +echo "SRC_ACTOR=$SRC_ACTOR" >> .env +echo "SRC_TOKEN=$SRC_TOKEN" >> .env + +echo "DST_REPOSITORY=$DST_REPOSITORY" >> .env +echo "DST_REF=$DST_REF" >> .env +echo "DST_ACTOR=$DST_ACTOR" >> .env +echo "DST_TOKEN=$DST_TOKEN" >> .env + +echo "OPT_RELEASE=$OPT_RELEASE" >> .env +echo "OPT_BUILD_STD=$OPT_BUILD_STD" >> .env +echo "OPT_UPX=$OPT_UPX" >> .env + +echo "GIT_FPUSH=$GIT_FPUSH" >> .env + +docker container run --attach --env-file .env --rm -t $BUILDER_IMAGE /bin/sh /build.sh +rm .env