Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS-7970] Add the option to select a tag for ADF upstream #4054

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/upstream-adf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ on:
schedule:
- cron: '0 */3 * * *' # “At minute 0 past every 3rd hour.”
workflow_dispatch:
inputs:
tag:
description: 'Type of the tag the latest version should be fetched with'
required: false
type: string
default: 'alpha'

env:
GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
Expand Down Expand Up @@ -30,11 +36,11 @@ jobs:
github-token: ${{ secrets.BOT_GITHUB_TOKEN }}
script: |
const getLatestVersionOf = require('./scripts/gh/update/latest-version-of.js');
const { hasNewVersion: hasNewADFVersion , remoteVersion: latestADFVersion } = await getLatestVersionOf({exec, github, dependencyName: 'adf-core'});
const { hasNewVersion: hasNewADFVersion , remoteVersion: latestADFVersion } = await getLatestVersionOf({exec, github, dependencyName: 'adf-core', tag: '${{ inputs.tag }}'});
console.log('hasNewADFVersion', hasNewADFVersion);
console.log('latestADFVersion', latestADFVersion?.name);

const { hasNewVersion: hasNewJSVersion, remoteVersion: latestJSVersion } = await getLatestVersionOf({exec, github, dependencyName: 'js-api'});
const { hasNewVersion: hasNewJSVersion, remoteVersion: latestJSVersion } = await getLatestVersionOf({exec, github, dependencyName: 'js-api', tag: '${{ inputs.tag }}'});
console.log('hasNewJSVersion', hasNewJSVersion);
console.log('latestJSVersion', latestJSVersion?.name);
if (hasNewADFVersion === 'true' || hasNewJSVersion === 'true' ) {
Expand Down
13 changes: 4 additions & 9 deletions scripts/gh/update/latest-version-of.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function inDays(d1, d2) {
return Math.floor((d2.getTime() - d1.getTime()) / (24 * 3600 * 1000));
}

module.exports = async ({ exec, github, dependencyName }) => {
module.exports = async ({ exec, github, dependencyName, tag }) => {
const organization = 'alfresco';
const dependencyFullName = `@${organization}/${dependencyName}`;
const pkg = require('../../../package.json');
Expand All @@ -15,7 +15,6 @@ module.exports = async ({ exec, github, dependencyName }) => {
org: organization
});

let latestPkgToUpdate = availablePackages[0];
const options = {};
let packageDistTag = '';
options.listeners = {
Expand All @@ -25,17 +24,13 @@ module.exports = async ({ exec, github, dependencyName }) => {
};
await exec.exec(`npm dist-tag ls @alfresco/${dependencyName}`, [], options);
const tagsType = packageDistTag.split('\n');
const latestPkgTag = tagsType.find((tag) => tag.includes(latestPkgToUpdate.name))?.split(':')[0];

if (latestPkgTag !== 'alpha') {
const alphaPackageVersion = tagsType.find((tag) => tag.includes('alpha'))?.split(':')[1].trim();
latestPkgToUpdate = availablePackages.find((item) => item.name === alphaPackageVersion);
}
const matchedPkgVersion = tagsType.find((tagType) => tagType.includes(tag))?.split(':')[1].trim();
const latestPkgToUpdate = availablePackages.find((package) => package.name === matchedPkgVersion);

if (localVersion === latestPkgToUpdate?.name) {
return { hasNewVersion: 'false' };
} else {
const findLocalVersionOnRemote = availablePackages.find((item) => item.name === localVersion);
const findLocalVersionOnRemote = availablePackages.find((package) => package.name === localVersion);
let rangeInDays = 'N/A';
if (findLocalVersionOnRemote !== undefined) {
const creationLocal = new Date(findLocalVersionOnRemote.created_at);
Expand Down
Loading