Skip to content
Open
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
| `error_count` | `false` | `"10"` | Maximum number of status report errors before cancelling a deployment (default: 10) |
| `reporting_interval` | `false` | `"5000"` | Time in milliseconds between two deployment status reports (default: 5 seconds) |
| `artifact_name` | `false` | `"github-pages"` | The name of the artifact to deploy |
| `artifact_id` | `false` | | ID of the artifact to deploy (overrides artifact_name if provided) |
| `preview` | `false` | `"false"` | Is this attempting to deploy a pull request as a GitHub Pages preview site? (NOTE: This feature is only in alpha currently and is not available to the public!) |

### Outputs 📤
Expand Down Expand Up @@ -131,3 +132,9 @@ The scripts and documentation in this project are released under the [MIT Licens
[draft-release]: .github/workflows/draft-release.yml
[release]: .github/workflows/release.yml
[release-workflow-runs]: https://github.com/actions/deploy-pages/actions/workflows/release.yml

## File Modification Dates

GitHub Pages deployments will set the modification date of uploaded files to the time of deployment, not the original file's last modified date. This is a limitation of the platform and cannot be changed by this action.

**Note:** If you provide `artifact_id`, it will be used directly for deployment and as the build version for uniqueness. This is useful if you have multiple artifacts with the same name in your workflow run.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ inputs:
description: 'Name of the artifact to deploy'
required: false
default: 'github-pages'
artifact_id:
description: 'ID of the artifact to deploy (overrides artifact_name if provided)'
required: false
preview:
description: 'Is this attempting to deploy a pull request as a GitHub Pages preview site? (NOTE: This feature is only in alpha currently and is not available to the public!)'
required: false
Expand Down
16 changes: 16 additions & 0 deletions src/__tests__/internal/deployment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,22 @@ describe('Deployment', () => {
)
twirpScope.done()
})

it('creates deployment using provided artifact_id and uses it as build version', async () => {
process.env.INPUT_ARTIFACT_ID = '1234567890';
// Set up the mock for the deployment creation
mockPool.intercept({
path: '/repos/actions/is-awesome/pages/deployments',
method: 'POST',
body: bodyString => {
const body = JSON.parse(bodyString);
return body.artifact_id === '1234567890' && body.pages_build_version === '1234567890';
}
}).reply(200, { id: '1234567890', status_url: 'https://api.github.com/repos/actions/is-awesome/pages/deployments/1234567890' }, { 'content-type': 'application/json' });
const deployment = new Deployment();
await deployment.create(fakeJwt);
delete process.env.INPUT_ARTIFACT_ID;
})
})

describe('#check', () => {
Expand Down
1 change: 1 addition & 0 deletions src/internal/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function getRequiredVars() {
githubApiUrl: process.env.GITHUB_API_URL ?? 'https://api.github.com',
githubServerUrl: process.env.GITHUB_SERVER_URL ?? 'https://github.com',
artifactName: core.getInput('artifact_name') || 'github-pages',
artifactId: core.getInput('artifact_id') || null,
isPreview: core.getInput('preview') === 'true'
}
}
Expand Down
22 changes: 17 additions & 5 deletions src/internal/deployment.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Deployment {
this.isPreview = context.isPreview === true
this.timeout = MAX_TIMEOUT
this.startTime = null
this.artifactId = context.artifactId
}

// Call GitHub api to fetch artifacts matching the provided name and deploy to GitHub Pages
Expand All @@ -62,7 +63,18 @@ class Deployment {
core.debug(`Action ID: ${this.actionsId}`)
core.debug(`Actions Workflow Run ID: ${this.workflowRun}`)

const artifactData = await getArtifactMetadata({ artifactName: this.artifactName })
let artifactData = null;
let artifactIdToUse = this.artifactId;
let buildVersionToUse = this.buildVersion;

if (artifactIdToUse) {
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding an inline comment explaining that when artifact_id is provided, artifactData is not fetched and the size check is skipped. This will clarify the intended behavior for future maintainers.

Copilot uses AI. Check for mistakes.

// If artifact_id is provided, use it directly and set buildVersion to artifact_id for uniqueness
buildVersionToUse = artifactIdToUse;
core.info(`Using provided artifact_id: ${artifactIdToUse}`);
} else {
artifactData = await getArtifactMetadata({ artifactName: this.artifactName });
artifactIdToUse = artifactData.id;
}

if (artifactData?.size > ONE_GIGABYTE) {
core.warning(
Expand All @@ -72,22 +84,22 @@ class Deployment {

const deployment = await createPagesDeployment({
githubToken: this.githubToken,
artifactId: artifactData.id,
buildVersion: this.buildVersion,
artifactId: artifactIdToUse,
buildVersion: buildVersionToUse,
idToken,
isPreview: this.isPreview
})

if (deployment) {
this.deploymentInfo = {
...deployment,
id: deployment.id || deployment.status_url?.split('/')?.pop() || this.buildVersion,
id: deployment.id || deployment.status_url?.split('/')?.pop() || buildVersionToUse,
pending: true
}
this.startTime = Date.now()
}

core.info(`Created deployment for ${this.buildVersion}, ID: ${this.deploymentInfo?.id}`)
core.info(`Created deployment for ${buildVersionToUse}, ID: ${this.deploymentInfo?.id}`)

core.debug(JSON.stringify(deployment))

Expand Down