mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-22 14:05:39 +00:00
WORKFLOW: reworked cooker workflow to ensure that RetroDECK Organization related patterns are not executed on a foregin repository making it fail
This commit is contained in:
parent
a26aafabef
commit
b4253b7f10
44
.github/workflows/cooker-selfhosted.yml
vendored
44
.github/workflows/cooker-selfhosted.yml
vendored
|
@ -41,6 +41,7 @@ jobs:
|
|||
continue-on-error: true
|
||||
|
||||
- name: Generate a token for Rekku
|
||||
if: github.repository_owner == 'RetroDECK'
|
||||
id: generate-rekku-token
|
||||
uses: actions/create-github-app-token@v1
|
||||
with:
|
||||
|
@ -52,6 +53,8 @@ jobs:
|
|||
- name: Clone RetroDECK repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.ref || github.ref }} # Use the branch or commit reference from the pull request if available; otherwise, fall back to the reference from the event that triggered the workflow.
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} # Use the repository name from the pull request if available; otherwise, use the repository name from the event that triggered the workflow.
|
||||
submodules: 'true'
|
||||
|
||||
- name: "Install dependencies"
|
||||
|
@ -73,22 +76,30 @@ jobs:
|
|||
echo "MAKE_LATEST=true" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
# if the branch is coming from a PR the tag should be manually built
|
||||
# Generate version tag based on the branch name: if the branch is coming from a PR the tag should be manually built
|
||||
- name: "Generate version tag"
|
||||
run: |
|
||||
|
||||
# Source version extractor script and get manifest version
|
||||
source automation_tools/version_extractor.sh
|
||||
MANIFEST_VERSION="$(fetch_manifest_version)"
|
||||
|
||||
# Set manifest version to environment variable
|
||||
echo "MANIFEST_VERSION=$MANIFEST_VERSION" >> $GITHUB_ENV
|
||||
if [[ "$BRANCH_NAME" == 'refs/'* ]]; then
|
||||
pr_number=$(echo ${{env.BRANCH_NAME}} | awk -F'/' '{print $3}')
|
||||
source_branch=$(curl -s "https://api.github.com/repos/RetroDECK/RetroDECK/pulls/$pr_number" | jq -r '.head.ref')
|
||||
source_branch=${source_branch//\//-}
|
||||
echo "[DEBUG] source branch is: $source_branch"
|
||||
echo "TAG=PR-$pr_number-$source_branch-${{ env.buildid }}" >> $GITHUB_ENV
|
||||
|
||||
# Determine tag based on branch type
|
||||
if [[ "$BRANCH_NAME" == refs/* ]]; then
|
||||
pr_number=$(echo "${{ env.BRANCH_NAME }}" | awk -F'/' '{print $3}')
|
||||
source_branch=$(curl -s "https://api.github.com/repos/RetroDECK/RetroDECK/pulls/$pr_number" | jq -r '.head.ref' | tr '/' '-')
|
||||
TAG="PR-$pr_number-$source_branch-${{ env.buildid }}"
|
||||
else
|
||||
TAG="$MANIFEST_VERSION-${{ env.buildid }}"
|
||||
echo "TAG=$TAG" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
# Set tag to environment variable
|
||||
echo "TAG=$TAG" >> $GITHUB_ENV
|
||||
|
||||
# Output debug information
|
||||
echo "MANIFEST_VERSION: $MANIFEST_VERSION"
|
||||
echo "Version TAG: $TAG"
|
||||
|
||||
|
@ -129,10 +140,6 @@ jobs:
|
|||
|
||||
- name: Create Bundle
|
||||
run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/flatpak_build_bundle.sh"
|
||||
|
||||
- name: Set environment variable with current branch name
|
||||
run: echo "GITHUB_REF_SLUG=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV
|
||||
|
||||
- name: Get commits since last release
|
||||
run: |
|
||||
# Get the latest release tag
|
||||
|
@ -140,21 +147,21 @@ jobs:
|
|||
# Get all commits since the latest release tag
|
||||
COMMITS=$(git log $LATEST_TAG..HEAD --pretty=format:"- %s")
|
||||
# Set the output variable
|
||||
echo "::set-output name=commits::$COMMITS"
|
||||
id: commits
|
||||
echo "COMMITS=$COMMITS" >> $GITHUB_ENV
|
||||
continue-on-error: true
|
||||
|
||||
- name: Publish the flatpak in a new cooker release
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
tag: "${{env.TAG}}"
|
||||
commit: ${{ github.sha }}
|
||||
body: |
|
||||
# Release Notes (Cooker)
|
||||
This is a cooker snapshot based on the commit: ${{ github.event.repository.full_name }}@${{github.sha}}.
|
||||
On branch [${{env.BRANCH_NAME}}](https://github.com/RetroDECK/RetroDECK/tree/${{env.BRANCH_NAME}}).
|
||||
|
||||
## Commits since last release
|
||||
${{ steps.commits.outputs.commits }}
|
||||
## Commits since last cooker build
|
||||
${{ env.COMMITS }}
|
||||
|
||||
For the full release note for this build please refer to the channel [#BETA-TESTING](https://discord.gg/WDc5C9YWMx) on our Discord server.
|
||||
|
||||
|
@ -165,10 +172,11 @@ jobs:
|
|||
allowUpdates: true
|
||||
makeLatest: ${{env.MAKE_LATEST}} # if it's a feat branch is not considered the latest build
|
||||
token: ${{ steps.generate-rekku-token.outputs.token }}
|
||||
repo: Cooker
|
||||
repo: ${{ github.repository_owner == 'RetroDECK' && 'Cooker' || github.repository }} # If the repo owner is RetroDECK, publish to Cooker, otherwise publish to the current fork repo
|
||||
continue-on-error: true
|
||||
|
||||
- name: Rewrite Tag
|
||||
if: github.repository_owner == 'RetroDECK'
|
||||
run: |
|
||||
git submodule deinit -f --all
|
||||
git fetch --tags
|
||||
|
@ -192,6 +200,7 @@ jobs:
|
|||
continue-on-error: true
|
||||
|
||||
- name: Create Artifact for flathub
|
||||
if: github.repository_owner == 'RetroDECK'
|
||||
run: |
|
||||
tar -czf ${GITHUB_WORKSPACE}/RetroDECK-Artifact-cooker.tar.gz -C ${GITHUB_WORKSPACE}/retrodeck-flatpak-cooker .
|
||||
hash=($(sha256sum ${GITHUB_WORKSPACE}/RetroDECK-Artifact-cooker.tar.gz))
|
||||
|
@ -200,6 +209,7 @@ jobs:
|
|||
continue-on-error: true
|
||||
|
||||
# - name: Upload RetroDECK-cooker.flatpak to Gitea Release
|
||||
# if: github.repository_owner == 'RetroDECK'
|
||||
# run: |
|
||||
# # Set variables for Gitea host, organization, repository, access token, and release details
|
||||
# GITEA_HOST="repo.retrodeck.net"
|
||||
|
|
Loading…
Reference in a new issue