Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
9 changes: 2 additions & 7 deletions components/apify/actions/run-actor/run-actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
key: "apify-run-actor",
name: "Run Actor",
description: "Performs an execution of a selected Actor in Apify. [See the documentation](https://docs.apify.com/api/v2#/reference/actors/run-collection/run-actor)",
version: "0.0.7",
version: "0.0.8",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down Expand Up @@ -300,12 +300,7 @@ export default {
}

if (buildTag) {
const taggedBuilds = actorDetails.taggedBuilds || {};
if (!taggedBuilds[buildTag]) {
throw new Error(
`Build with tag "${buildTag}" was not found for actor "${actorDetails.title || actorDetails.name}".`,
);
}
await apify.resolveBuildId(actorId, buildTag);
}

// Prepare input
Expand Down
54 changes: 38 additions & 16 deletions components/apify/apify.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,25 @@ export default {
buildTag: {
type: "string",
label: "Build",
description: "Specifies the Actor build to run. The accepted value is the build tag. If not provided, the default build will be used.",
description: "Actor build to run. Pick a tag from the list or enter a build number (e.g. `0.1.2`). Defaults to the Actor's default build.",
async options({ actorId }) {
const { taggedBuilds } = await this.getActor({
if (!actorId) {
return [];
}

const { taggedBuilds = {} } = await this.getActor({
actorId,
});

return Object.entries(taggedBuilds).map(([
name,
]) => name);
tag,
info,
]) => ({
label: info?.buildNumber
? `${tag} (${info.buildNumber})`
: tag,
value: tag,
}));
},
},
clean: {
Expand Down Expand Up @@ -200,29 +210,41 @@ export default {
return this._client().actor(actorId)
.get();
},
async getBuild(actorId, buildTag) {
// Get actor details
async resolveBuildId(actorId, buildRef) {
const actor = await this._client().actor(actorId)
.get();

if (!actor) {
throw new Error(`Actor ${actorId} not found.`);
}

if (!buildTag) {
buildTag = actor.defaultRunOptions.build;
if (!buildRef) {
buildRef = actor.defaultRunOptions.build;
}

const { taggedBuilds } = actor;
const taggedBuilds = actor.taggedBuilds ?? {};

if (taggedBuilds[buildTag]) {
return this._client().build(taggedBuilds[buildTag].buildId)
.get();
} else {
throw new Error(
`Actor ${actorId} has no build tagged "${buildTag}". Please build the actor first.`,
);
if (taggedBuilds[buildRef]?.buildId) {
return taggedBuilds[buildRef].buildId;
}

const { items: builds = [] } = await this.listBuilds({
Comment thread
daveomri marked this conversation as resolved.
actorId,
});
const match = builds.find(({ buildNumber }) => buildNumber === buildRef);

if (match) {
return match.id;
}

throw new Error(
`No build with tag or number "${buildRef}" found for actor ${actorId}.`,
);
},
async getBuild(actorId, buildRef) {
const buildId = await this.resolveBuildId(actorId, buildRef);
return this._client().build(buildId)
.get();
},
listActors(opts = {}) {
return this._client().store()
Expand Down
2 changes: 1 addition & 1 deletion components/apify_oauth/actions/run-actor/run-actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const props = adjustPropDefinitions(others.props, app);
export default {
...others,
key: "apify_oauth-run-actor",
version: "0.0.2",
version: "0.0.4",
name,
description,
type,
Expand Down