custom_event #292
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: Release to Github and artifact | ||
on: | ||
workflow_dispatch: | ||
repository_dispatch: | ||
types: [custom_event] | ||
jobs: | ||
release: | ||
name: Release to github and artifact | ||
runs-on: ubuntu-latest | ||
env: | ||
CI: false | ||
appname: library | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.client_payload.branch }} | ||
- name: Version convert | ||
id: convert_version | ||
run: | | ||
BRANCH_NAME=${{ github.event.client_payload.branch }} | ||
curl https://raw.githubusercontent.com/Websoft9/websoft9/${BRANCH_NAME}/docker/apphub/Dockerfile -o Dockerfile | ||
library_tag=$(grep 'ARG LIBRARY_VERSION' "Dockerfile" | cut -d'"' -f2 | xargs) | ||
apphub_tag=$(grep 'LABEL version' "Dockerfile" | cut -d'"' -f2 | xargs) | ||
# Determine the channel based on the branch and apphub_tag | ||
if [[ "$BRANCH_NAME" == "dev" ]]; then | ||
echo "CHANNEL=dev" >> $GITHUB_ENV | ||
elif [[ "$BRANCH_NAME" == "main" ]]; then | ||
if [[ "$apphub_tag" == *"-"* ]]; then | ||
suffix="${apphub_tag#*-}" | ||
library_tag_gh="${library_tag}-${suffix}" | ||
echo "CHANNEL=rc" >> $GITHUB_ENV | ||
else | ||
library_tag_gh=$library_tag | ||
echo "CHANNEL=release" >> $GITHUB_ENV | ||
fi | ||
fi | ||
# Set library_tag_gh based on apphub_tag | ||
if [[ "$apphub_tag" == *"-"* ]]; then | ||
suffix="${apphub_tag#*-}" | ||
library_tag_gh="${library_tag}-${suffix}" | ||
else | ||
library_tag_gh=$library_tag | ||
fi | ||
echo "LIBRARY_TAG=$library_tag" >> $GITHUB_ENV | ||
echo "LIBRARY_TAG_GH=$library_tag_gh" >> $GITHUB_ENV | ||
jq --arg version "$library_tag_gh" '.Version = $version' library.json > temp.json && mv temp.json library.json | ||
- name: Create Zip Archive for artifact | ||
run: | | ||
mkdir ${{ env.appname }} artifacts | ||
cp -r apps ${{ env.appname }} | ||
cp -r docs ${{ env.appname }} | ||
cp -r template ${{ env.appname }} | ||
cp *.md ${{ env.appname }} | ||
cp ${{ env.appname }}.json ${{ env.appname }} | ||
cp ${{ env.appname }}.json CHANGELOG.md artifacts | ||
zip -r ${{ env.appname }}-${{ env.LIBRARY_TAG }}.zip ${{ env.appname }} | ||
cp ${{ env.appname }}-${{ env.LIBRARY_TAG }}.zip artifacts | ||
cp artifacts/${{ env.appname }}-${{ env.LIBRARY_TAG }}.zip artifacts/${{ env.appname }}-latest.zip | ||
- name: Upload To cloudflare r2 | ||
uses: ryand56/r2-upload-action@latest | ||
with: | ||
r2-account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
r2-access-key-id: ${{ secrets.CLOUDFLARE_SECRET_ID }} | ||
r2-secret-access-key: ${{ secrets.CLOUDFLARE_SECRET_KEY }} | ||
r2-bucket: artifact | ||
source-dir: artifacts | ||
destination-dir: ./${{ env.CHANNEL }}/websoft9/plugin/${{ env.appname }} | ||
- name: Create Github Release from code | ||
if: env.CHANNEL != 'dev' | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
${{ env.appname }}.json | ||
tag_name: ${{ env.LIBRARY_TAG_GH }} | ||
name: ${{ env.LIBRARY_TAG_GH }} | ||
draft: false | ||
prerelease: false | ||
pages: | ||
name: Build Github Pages | ||
if: env.CHANNEL != 'dev' | ||
Check failure on line 93 in .github/workflows/release.yml GitHub Actions / Release to Github and artifactInvalid workflow file
|
||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Pages | ||
uses: actions/configure-pages@v4 | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v2 | ||
with: | ||
# Upload entire repository | ||
path: '.' | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v3 |