revert dep changes and fix jenkins vars typo

This commit is contained in:
thelamer 2023-04-01 19:28:45 -07:00
parent 75ae916249
commit 0d16c7b44f
4 changed files with 103 additions and 35 deletions

View File

@ -12,5 +12,80 @@ jobs:
- name: External Trigger
if: github.ref == 'refs/heads/master'
run: |
echo "**** No external release, exiting ****"
exit 0
if [ -n "${{ secrets.PAUSE_EXTERNAL_TRIGGER_GITHUB_DESKTOP_MASTER }}" ]; then
echo "**** Github secret PAUSE_EXTERNAL_TRIGGER_GITHUB_DESKTOP_MASTER is set; skipping trigger. ****"
exit 0
fi
echo "**** External trigger running off of master branch. To disable this trigger, set a Github secret named \"PAUSE_EXTERNAL_TRIGGER_GITHUB_DESKTOP_MASTER\". ****"
echo "**** Retrieving external version ****"
EXT_RELEASE=$(curl -u "${{ secrets.CR_USER }}:${{ secrets.CR_PAT }}" -sX GET "https://api.github.com/repos/shiftkey/desktop/releases/latest" | jq -r '. | .tag_name')
if [ -z "${EXT_RELEASE}" ] || [ "${EXT_RELEASE}" == "null" ]; then
echo "**** Can't retrieve external version, exiting ****"
FAILURE_REASON="Can't retrieve external version for github-desktop branch master"
GHA_TRIGGER_URL="https://github.com/linuxserver/docker-github-desktop/actions/runs/${{ github.run_id }}"
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 16711680,
"description": "**Trigger Failed** \n**Reason:** '"${FAILURE_REASON}"' \n**Trigger URL:** '"${GHA_TRIGGER_URL}"' \n"}],
"username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }}
exit 1
fi
EXT_RELEASE=$(echo ${EXT_RELEASE} | sed 's/[~,%@+;:/]//g')
echo "**** External version: ${EXT_RELEASE} ****"
echo "**** Retrieving last pushed version ****"
image="linuxserver/github-desktop"
tag="latest"
token=$(curl -sX GET \
"https://ghcr.io/token?scope=repository%3Alinuxserver%2Fgithub-desktop%3Apull" \
| jq -r '.token')
digest=$(curl -s \
--header "Accept: application/vnd.docker.distribution.manifest.v2+json" \
--header "Authorization: Bearer ${token}" \
"https://ghcr.io/v2/${image}/manifests/${tag}" \
| jq -r '.config.digest')
image_info=$(curl -sL \
--header "Authorization: Bearer ${token}" \
"https://ghcr.io/v2/${image}/blobs/${digest}")
if [[ $(echo $image_info | jq -r '.container_config') == "null" ]]; then
image_info=$(echo $image_info | jq -r '.config')
else
image_info=$(echo $image_info | jq -r '.container_config')
fi
IMAGE_RELEASE=$(echo ${image_info} | jq -r '.Labels.build_version' | awk '{print $3}')
IMAGE_VERSION=$(echo ${IMAGE_RELEASE} | awk -F'-ls' '{print $1}')
if [ -z "${IMAGE_VERSION}" ]; then
echo "**** Can't retrieve last pushed version, exiting ****"
FAILURE_REASON="Can't retrieve last pushed version for github-desktop tag latest"
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 16711680,
"description": "**Trigger Failed** \n**Reason:** '"${FAILURE_REASON}"' \n"}],
"username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }}
exit 1
fi
echo "**** Last pushed version: ${IMAGE_VERSION} ****"
if [ "${EXT_RELEASE}" == "${IMAGE_VERSION}" ]; then
echo "**** Version ${EXT_RELEASE} already pushed, exiting ****"
exit 0
elif [ $(curl -s https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-github-desktop/job/master/lastBuild/api/json | jq -r '.building') == "true" ]; then
echo "**** New version ${EXT_RELEASE} found; but there already seems to be an active build on Jenkins; exiting ****"
exit 0
else
echo "**** New version ${EXT_RELEASE} found; old version was ${IMAGE_VERSION}. Triggering new build ****"
response=$(curl -iX POST \
https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-github-desktop/job/master/buildWithParameters?PACKAGE_CHECK=false \
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} | grep -i location | sed "s|^[L|l]ocation: \(.*\)|\1|")
echo "**** Jenkins job queue url: ${response%$'\r'} ****"
echo "**** Sleeping 10 seconds until job starts ****"
sleep 10
buildurl=$(curl -s "${response%$'\r'}api/json" | jq -r '.executable.url')
buildurl="${buildurl%$'\r'}"
echo "**** Jenkins job build url: ${buildurl} ****"
echo "**** Attempting to change the Jenkins job description ****"
curl -iX POST \
"${buildurl}submitDescription" \
--user ${{ secrets.JENKINS_USER }}:${{ secrets.JENKINS_TOKEN }} \
--data-urlencode "description=GHA external trigger https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
--data-urlencode "Submit=Submit"
echo "**** Notifying Discord ****"
TRIGGER_REASON="A version change was detected for github-desktop tag latest. Old version:${IMAGE_VERSION} New version:${EXT_RELEASE}"
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903,
"description": "**Build Triggered** \n**Reason:** '"${TRIGGER_REASON}"' \n**Build URL:** '"${buildurl}display/redirect"' \n"}],
"username": "Github Actions"}' ${{ secrets.DISCORD_WEBHOOK }}
fi

View File

@ -13,24 +13,8 @@ RUN \
apt-get install --no-install-recommends -y \
chromium \
git \
gnome-keyring \
gvfs-bin \
kde-cli-tools \
libatk1.0-0 \
libatk-bridge2.0-0 \
libatspi2.0-0 \
libcups2 \
libglib2.0-0 \
libglib2.0-bin \
libgtk-3-0 \
libnotify4 \
libnspr4 \
libnss3 \
libsecret-1-0 \
libxtst6 \
ssh-askpass \
thunar \
trash-cli \
xfce4-terminal && \
echo "**** install github-desktop ****" && \
if [ -z ${GHDESKTOP_VERSION+x} ]; then \
@ -40,14 +24,14 @@ RUN \
curl -o \
/tmp/ghdesktop.deb -L \
"https://github.com/shiftkey/desktop/releases/download/${GHDESKTOP_VERSION}/GitHubDesktop-linux-${GHDESKTOP_VERSION#release-}.deb" && \
dpkg -i /tmp/ghdesktop.deb && \
apt install --no-install-recommends -y /tmp/ghdesktop.deb && \
echo "**** install codium ****" && \
CODIUM_VERSION=$(curl -sX GET "https://api.github.com/repos/VSCodium/vscodium/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
curl -o \
/tmp/codium.deb -L \
"https://github.com/VSCodium/vscodium/releases/download/${CODIUM_VERSION}/codium_${CODIUM_VERSION}_amd64.deb" && \
dpkg -i /tmp/codium.deb && \
apt install --no-install-recommends -y /tmp/codium.deb && \
echo "**** container tweaks ****" && \
ln -s \
/usr/bin/xfce4-terminal \

33
Jenkinsfile vendored
View File

@ -17,10 +17,10 @@ pipeline {
GITLAB_TOKEN=credentials('b6f0f1dd-6952-4cf6-95d1-9c06380283f0')
GITLAB_NAMESPACE=credentials('gitlab-namespace-id')
SCARF_TOKEN=credentials('scarf_api_key')
BUILD_VERSION_ARG = 'GHDESKTOP_VERSION'
EXT_GIT_BRANCH = 'master'
EXT_USER = 'shiftkey'
EXT_REPO = 'desktop'
BUILD_VERSION_ARG = 'GHDESKTOP_VERSION'
LS_USER = 'linuxserver'
LS_REPO = 'docker-github-desktop'
CONTAINER_NAME = 'github-desktop'
@ -102,14 +102,23 @@ pipeline {
/* ########################
External Release Tagging
######################## */
// If this is an os release set release type to none to indicate no external release
stage("Set ENV os"){
steps{
script{
env.EXT_RELEASE = env.PACKAGE_TAG
env.RELEASE_LINK = 'none'
}
}
// If this is a stable github release use the latest endpoint from github to determine the ext tag
stage("Set ENV github_stable"){
steps{
script{
env.EXT_RELEASE = sh(
script: '''curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq -r '. | .tag_name' ''',
returnStdout: true).trim()
}
}
}
// If this is a stable or devel github release generate the link for the build message
stage("Set ENV github_link"){
steps{
script{
env.RELEASE_LINK = 'https://github.com/' + env.EXT_USER + '/' + env.EXT_REPO + '/releases/tag/' + env.EXT_RELEASE
}
}
}
// Sanitize the release tag and strip illegal docker or github characters
stage("Sanitize tag"){
@ -899,12 +908,12 @@ pipeline {
"tagger": {"name": "LinuxServer Jenkins","email": "jenkins@linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
echo "Pushing New release for Tag"
sh '''#! /bin/bash
echo "Updating base packages to ${PACKAGE_TAG}" > releasebody.json
curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq '. |.body' | sed 's:^.\\(.*\\).$:\\1:' > releasebody.json
echo '{"tag_name":"'${META_TAG}'",\
"target_commitish": "master",\
"name": "'${META_TAG}'",\
"body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n\\n**OS Changes:**\\n\\n' > start
printf '","draft": false,"prerelease": }' >> releasebody.json
"body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n\\n**'${EXT_REPO}' Changes:**\\n\\n' > start
printf '","draft": false,"prerelease": false}' >> releasebody.json
paste -d'\\0' start releasebody.json > releasebody.json.done
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases -d @releasebody.json.done'''
}

View File

@ -2,15 +2,15 @@
# jenkins variables
project_name: docker-github-desktop
external_type: os
release_type: github_stable
external_type: github_stable
release_type: stable
release_tag: latest
ls_branch: master
repo_vars:
- BUILD_VERSION_ARG = 'GHDESKTOP_VERSION'
- EXT_GIT_BRANCH = 'master'
- EXT_USER = 'shiftkey'
- EXT_REPO = 'desktop'
- BUILD_VERSION_ARG = 'GHDESKTOP_VERSION'
- LS_USER = 'linuxserver'
- LS_REPO = 'docker-github-desktop'
- CONTAINER_NAME = 'github-desktop'