Testing the token pass as a secret

This commit is contained in:
XargonWan 2024-11-13 13:06:45 +09:00
parent eaa5cafdfe
commit 83047840a2

View file

@ -29,226 +29,226 @@ permissions:
jobs: jobs:
# Build RetroDECK Job # Build RetroDECK Job
Build_RetroDECK: # Build_RetroDECK:
runs-on: retrodeck-server # runs-on: retrodeck-server
outputs: # outputs:
tag: ${{ steps.set-outputs.outputs.tag }} # tag: ${{ steps.set-outputs.outputs.tag }}
release_body: ${{ steps.set-outputs.outputs.release_body }} # release_body: ${{ steps.set-outputs.outputs.release_body }}
env: # env:
REKKU_TOKEN: ${{ needs.Generate-Rekku-Token.outputs.rekku_token }} # REKKU_TOKEN: ${{ needs.Generate-Rekku-Token.outputs.rekku_token }}
steps: # steps:
# Remove Stuck Mounts # # Remove Stuck Mounts
- name: Remove stuck mounts # - name: Remove stuck mounts
run: | # run: |
sudo umount -f /home/ubuntu/actions-runner/_work/RetroDECK/RetroDECK/.flatpak-builder/rofiles/* # sudo umount -f /home/ubuntu/actions-runner/_work/RetroDECK/RetroDECK/.flatpak-builder/rofiles/*
sudo umount -f $HOME/actions-run/_work/RetroDECK/RetroDECK/.flatpak-builder/rofiles/* # sudo umount -f $HOME/actions-run/_work/RetroDECK/RetroDECK/.flatpak-builder/rofiles/*
continue-on-error: true # continue-on-error: true
# Clone Repository # # Clone Repository
- name: Clone RetroDECK repo # - name: Clone RetroDECK repo
uses: actions/checkout@v4 # uses: actions/checkout@v4
with: # with:
submodules: true # submodules: true
# Install Dependencies # # Install Dependencies
- name: Install dependencies # - name: Install dependencies
run: curl "https://raw.githubusercontent.com/RetroDECK/components-template/main/automation_tools/install_dependencies.sh" | bash # run: curl "https://raw.githubusercontent.com/RetroDECK/components-template/main/automation_tools/install_dependencies.sh" | bash
# Generate Build ID for Cooker Branches # # Generate Build ID for Cooker Branches
- name: Generate cooker build ID # - name: Generate cooker build ID
if: github.ref != 'refs/heads/main' # if: github.ref != 'refs/heads/main'
run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/cooker_build_id.sh" # run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/cooker_build_id.sh"
# Get Branch Name # # Get Branch Name
- name: Get branch name # - name: Get branch name
id: get-branch-name # id: get-branch-name
run: | # run: |
branch_name=$(echo $GITHUB_REF | sed 's|refs/heads/||') # branch_name=$(echo $GITHUB_REF | sed 's|refs/heads/||')
echo "BRANCH_NAME=$branch_name" >> $GITHUB_ENV # echo "BRANCH_NAME=$branch_name" >> $GITHUB_ENV
# Generate Version Tag # # Generate Version Tag
- name: Generate version tag # - name: Generate version tag
id: set-outputs # id: set-outputs
run: | # run: |
source automation_tools/version_extractor.sh # source automation_tools/version_extractor.sh
MANIFEST_VERSION="$(fetch_manifest_version)" # MANIFEST_VERSION="$(fetch_manifest_version)"
if [[ "$GITHUB_REF" == "refs/heads/main" ]]; then # if [[ "$GITHUB_REF" == "refs/heads/main" ]]; then
TAG="$MANIFEST_VERSION" # TAG="$MANIFEST_VERSION"
MAKE_LATEST=true # MAKE_LATEST=true
else # else
source_branch="${GITHUB_HEAD_REF//\//-}" # source_branch="${GITHUB_HEAD_REF//\//-}"
TAG="PR-$source_branch-${{ github.run_id }}" # TAG="PR-$source_branch-${{ github.run_id }}"
MAKE_LATEST=false # MAKE_LATEST=false
fi # fi
echo "tag=$TAG" >> $GITHUB_OUTPUT # echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "MAKE_LATEST=$MAKE_LATEST" >> $GITHUB_ENV # echo "MAKE_LATEST=$MAKE_LATEST" >> $GITHUB_ENV
# if the branch is coming from a PR the tag should be manually built # # if the branch is coming from a PR the tag should be manually built
- name: "Generate version tag and evaluating latest tag" # - name: "Generate version tag and evaluating latest tag"
run: | # run: |
# Source the version extractor script to get the manifest version # # Source the version extractor script to get the manifest version
source automation_tools/version_extractor.sh # source automation_tools/version_extractor.sh
MANIFEST_VERSION="$(fetch_manifest_version)" # MANIFEST_VERSION="$(fetch_manifest_version)"
echo "MANIFEST_VERSION=$MANIFEST_VERSION" >> $GITHUB_ENV # echo "MANIFEST_VERSION=$MANIFEST_VERSION" >> $GITHUB_ENV
# Check if the event is related to a pull request # # Check if the event is related to a pull request
if [[ "$GITHUB_EVENT_NAME" == "pull_request" || "$GITHUB_EVENT_NAME" == "pull_request_target" ]]; then # if [[ "$GITHUB_EVENT_NAME" == "pull_request" || "$GITHUB_EVENT_NAME" == "pull_request_target" ]]; then
# Use GITHUB_HEAD_REF to get the source branch # # Use GITHUB_HEAD_REF to get the source branch
source_branch="${GITHUB_HEAD_REF}" # source_branch="${GITHUB_HEAD_REF}"
# Replace '/' with '-' in the branch name # # Replace '/' with '-' in the branch name
source_branch=${source_branch//\//-} # source_branch=${source_branch//\//-}
# Use GITHUB_HEAD_REF to get the source branch # # Use GITHUB_HEAD_REF to get the source branch
source_branch="${GITHUB_HEAD_REF}" # source_branch="${GITHUB_HEAD_REF}"
# Replace '/' with '-' in the branch name # # Replace '/' with '-' in the branch name
source_branch=${source_branch//\//-} # source_branch=${source_branch//\//-}
echo "[DEBUG] source branch is: $source_branch" # echo "[DEBUG] source branch is: $source_branch"
# Generate the tag for a pull request # # Generate the tag for a pull request
echo "TAG=PR-$source_branch-${{ env.buildid }}" >> $GITHUB_ENV # echo "TAG=PR-$source_branch-${{ env.buildid }}" >> $GITHUB_ENV
echo "MAKE_LATEST=false" >> $GITHUB_OUTPUT # Not marked as the latest cooker version if it's a feature branch # echo "MAKE_LATEST=false" >> $GITHUB_OUTPUT # Not marked as the latest cooker version if it's a feature branch
else # else
# Generate the tag for non-pull request branches # # Generate the tag for non-pull request branches
TAG="$MANIFEST_VERSION-${{ env.buildid }}" # TAG="$MANIFEST_VERSION-${{ env.buildid }}"
echo "TAG=$TAG" >> $GITHUB_ENV # echo "TAG=$TAG" >> $GITHUB_ENV
echo "MAKE_LATEST=true" >> $GITHUB_OUTPUT # echo "MAKE_LATEST=true" >> $GITHUB_OUTPUT
fi # fi
# Output the manifest version and generated tag for debugging # # Output the manifest version and generated tag for debugging
echo "MANIFEST_VERSION: $MANIFEST_VERSION" # echo "MANIFEST_VERSION: $MANIFEST_VERSION"
echo "Version TAG: $TAG" # echo "Version TAG: $TAG"
echo "MAKE_LATEST: $MAKE_LATEST" # echo "MAKE_LATEST: $MAKE_LATEST"
# backing up manifest in case download fails and hashes must be recalculated # # backing up manifest in case download fails and hashes must be recalculated
- name: Manifest backup # - name: Manifest backup
run: "cp ${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml ${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml.bak" # run: "cp ${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml ${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml.bak"
- name: Run pre-build automation tasks # - name: Run pre-build automation tasks
run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/pre_build_automation.sh" # run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/pre_build_automation.sh"
- name: "Adding flatpak portal for automated updates (Cooker only)" # - name: "Adding flatpak portal for automated updates (Cooker only)"
if: github.ref != 'refs/heads/main' # if: github.ref != 'refs/heads/main'
run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/cooker_flatpak_portal_add.sh" # run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/cooker_flatpak_portal_add.sh"
- name: "Updating release notes in appdata" # - name: "Updating release notes in appdata"
run: "automation_tools/appdata_management.sh" # run: "automation_tools/appdata_management.sh"
- name: "[DEBUG] Outputting manifest" # - name: "[DEBUG] Outputting manifest"
run: cat net.retrodeck.retrodeck.yml # run: cat net.retrodeck.retrodeck.yml
# Get Commits Since Last Release # # Get Commits Since Last Release
- name: Get commits since last release # - name: Get commits since last release
id: get-commits # id: get-commits
run: | # run: |
LATEST_TAG=$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1 --first-parent) || echo "") # LATEST_TAG=$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1 --first-parent) || echo "")
if [ -z "$LATEST_TAG" ]; then # if [ -z "$LATEST_TAG" ]; then
COMMITS=$(git log HEAD --pretty=format:"- %s") # COMMITS=$(git log HEAD --pretty=format:"- %s")
else # else
COMMITS=$(git log ${LATEST_TAG}..HEAD --pretty=format:"- %s") # COMMITS=$(git log ${LATEST_TAG}..HEAD --pretty=format:"- %s")
fi # fi
echo "commits=$COMMITS" >> $GITHUB_OUTPUT # echo "commits=$COMMITS" >> $GITHUB_OUTPUT
# Generate Release Body # # Generate Release Body
- name: Generate release body text # - name: Generate release body text
id: generate-body # id: generate-body
run: | # run: |
# # Enable debugging # # # Enable debugging
# set -x # # set -x
# # Initialize the release body # # # Initialize the release body
# RELEASE_BODY="# Release Notes\n" # # RELEASE_BODY="# Release Notes\n"
# RELEASE_BODY+="This release is based on the commit: RetroDECK/RetroDECK@c8bd579ad4d0922ba7ab1f5c122cc782ff6adc66.\n" # # RELEASE_BODY+="This release is based on the commit: RetroDECK/RetroDECK@c8bd579ad4d0922ba7ab1f5c122cc782ff6adc66.\n"
# RELEASE_BODY+="On branch [cooker](https://github.com/RetroDECK/RetroDECK/tree/cooker).\n\n" # # RELEASE_BODY+="On branch [cooker](https://github.com/RetroDECK/RetroDECK/tree/cooker).\n\n"
# RELEASE_BODY+="## Commits since last release\n" # # RELEASE_BODY+="## Commits since last release\n"
# RELEASE_BODY+="- RELEASE NOTES: fixed body\n\n" # # RELEASE_BODY+="- RELEASE NOTES: fixed body\n\n"
# # Define the XML file path # # # Define the XML file path
# xml_file="./net.retrodeck.retrodeck.appdata.xml" # # xml_file="./net.retrodeck.retrodeck.appdata.xml"
# # Check if the XML file exists # # # Check if the XML file exists
# if [[ ! -f "$xml_file" ]]; then # # if [[ ! -f "$xml_file" ]]; then
# echo "Error: XML file not found: $xml_file" # # echo "Error: XML file not found: $xml_file"
# exit 1 # # exit 1
# fi # # fi
# # Extract the raw description content # # # Extract the raw description content
# raw_description=$(xmlstarlet sel -t -m "/component/releases/release[1]/description/*" -c "." -n "$xml_file" 2>/dev/null) # # raw_description=$(xmlstarlet sel -t -m "/component/releases/release[1]/description/*" -c "." -n "$xml_file" 2>/dev/null)
# # Check if xmlstarlet extraction was successful # # # Check if xmlstarlet extraction was successful
# if [[ $? -ne 0 ]]; then # # if [[ $? -ne 0 ]]; then
# echo "Error: Failed to extract description content using xmlstarlet" # # echo "Error: Failed to extract description content using xmlstarlet"
# exit 1 # # exit 1
# fi # # fi
# # Convert <p> tags to markdown headers using sed # # # Convert <p> tags to markdown headers using sed
# markdown_description=$(echo "$raw_description" | sed -e 's|<p>|\n### |g' -e 's|</p>||g') # # markdown_description=$(echo "$raw_description" | sed -e 's|<p>|\n### |g' -e 's|</p>||g')
# # Convert <li> tags to bullet points and trim spaces # # # Convert <li> tags to bullet points and trim spaces
# markdown_description=$(echo "$markdown_description" | sed -e 's|<ul>||g' -e 's|</ul>||g' -e 's|<li>|- |g' -e 's|</li>||g' | awk '{$1=$1;print}') # # markdown_description=$(echo "$markdown_description" | sed -e 's|<ul>||g' -e 's|</ul>||g' -e 's|<li>|- |g' -e 's|</li>||g' | awk '{$1=$1;print}')
# # Remove any remaining XML tags # # # Remove any remaining XML tags
# markdown_description=$(echo "$markdown_description" | sed -e 's/<[^>]*>//g') # # markdown_description=$(echo "$markdown_description" | sed -e 's/<[^>]*>//g')
# # Debug: Print the markdown description # # # Debug: Print the markdown description
# echo "Markdown Description:" # # echo "Markdown Description:"
# echo "$markdown_description" # # echo "$markdown_description"
# # Append markdown content with proper formatting # # # Append markdown content with proper formatting
# RELEASE_BODY+="$markdown_description\n" # # RELEASE_BODY+="$markdown_description\n"
# # Output the release body for GitHub Actions # # # Output the release body for GitHub Actions
# { # # {
# printf "release_body<<EOF\n%s\nEOF\n" "$RELEASE_BODY" # # printf "release_body<<EOF\n%s\nEOF\n" "$RELEASE_BODY"
# } >> "$GITHUB_OUTPUT" # # } >> "$GITHUB_OUTPUT"
# # Disable debugging # # # Disable debugging
# set +x # # set +x
RELEASE_BODY="# Release Notes\n" # RELEASE_BODY="# Release Notes\n"
- name: "Build flatpak: download only" # - name: "Build flatpak: download only"
run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/flatpak_build_download_only.sh" # run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/flatpak_build_download_only.sh"
# Sometimes flatpak download fails, in this case it tries a second time # # Sometimes flatpak download fails, in this case it tries a second time
- name: "Build flatpak: download only (retry)" # - name: "Build flatpak: download only (retry)"
if: steps.flatpak-download.outcome == 'failure' # if: steps.flatpak-download.outcome == 'failure'
run: | # run: |
echo "Download failed, maybe some hash changed since the build start." # echo "Download failed, maybe some hash changed since the build start."
echo "Recalculating hashes and retrying download..." # echo "Recalculating hashes and retrying download..."
rm -f "{GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml" # rm -f "{GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml"
cp "${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml.bak" "${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml" # cp "${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml.bak" "${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml"
"${GITHUB_WORKSPACE}/automation_tools/pre_build_automation.sh" # "${GITHUB_WORKSPACE}/automation_tools/pre_build_automation.sh"
"${GITHUB_WORKSPACE}/automation_tools/flatpak_build_download_only.sh" # "${GITHUB_WORKSPACE}/automation_tools/flatpak_build_download_only.sh"
- name: Build flatpak # - name: Build flatpak
run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/flatpak_build_only.sh" # run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/flatpak_build_only.sh"
- name: Create Bundle # - name: Create Bundle
run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/flatpak_build_bundle.sh" # run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/flatpak_build_bundle.sh"
# Upload artifacts for other jobs # # Upload artifacts for other jobs
- name: Upload Build Artifacts # - name: Upload Build Artifacts
uses: actions/upload-artifact@v4 # uses: actions/upload-artifact@v4
with: # with:
name: retrodeck-artifacts # name: retrodeck-artifacts
path: | # path: |
RetroDECK*.flatpak # RetroDECK*.flatpak
RetroDECK*.flatpak.sha # RetroDECK*.flatpak.sha
RetroDECK*Artifact.tar.gz # RetroDECK*Artifact.tar.gz
Generate-Rekku-Token: Generate-Rekku-Token:
uses: RetroDECK/components-template/.github/workflows/generate_rekku_token.yml@main uses: RetroDECK/components-template/.github/workflows/generate_rekku_token.yml@main
needs: Build_RetroDECK # needs: Build_RetroDECK
secrets: secrets:
REKKU_PRIVATE_KEY: ${{ secrets.REKKU_PRIVATE_KEY }} REKKU_PRIVATE_KEY: ${{ secrets.REKKU_PRIVATE_KEY }}
GitHub-publish: GitHub-publish:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [Generate-Rekku-Token, Build_RetroDECK] # needs: [Generate-Rekku-Token, Build_RetroDECK]
needs: [Generate-Rekku-Token]
env: env:
REKKU_TOKEN: ${{ needs.Generate-Rekku-Token.outputs.rekku_token }}
tag: ${{ needs.Build_RetroDECK.outputs.tag }} tag: ${{ needs.Build_RetroDECK.outputs.tag }}
release_body: ${{ needs.Build_RetroDECK.outputs.release_body }} release_body: ${{ needs.Build_RetroDECK.outputs.release_body }}
MAKE_LATEST: ${{ needs.Build_RetroDECK.outputs.MAKE_LATEST }} MAKE_LATEST: ${{ needs.Build_RetroDECK.outputs.MAKE_LATEST }}
@ -274,7 +274,7 @@ jobs:
artifacts: "*.flatpak,*.flatpak.sha,*Artifact.tar.gz" artifacts: "*.flatpak,*.flatpak.sha,*Artifact.tar.gz"
allowUpdates: true allowUpdates: true
makeLatest: ${{ env.MAKE_LATEST }} makeLatest: ${{ env.MAKE_LATEST }}
token: ${{ env.REKKU_TOKEN }} token: ${{ needs.Generate-Rekku-Token.outputs.rekku_token }}
repo: "${{ env.repo_name }}" repo: "${{ env.repo_name }}"
continue-on-error: ${{ github.ref != 'refs/heads/main' }} continue-on-error: ${{ github.ref != 'refs/heads/main' }}