Deploy Rust on Google Cloud C4A (Arm-based Axion VMs) #785
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Roadmap Date | |
| on: | |
| pull_request_target: | |
| types: [labeled] | |
| jobs: | |
| update-roadmap-dates: | |
| runs-on: ubuntu-latest | |
| if: | | |
| github.event.label.name == 'awaiting_tech_review' || | |
| github.event.label.name == 'publish' | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| repository-projects: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18.x' | |
| - name: Install Octokit | |
| run: npm install @octokit/rest | |
| - name: Update Project Board Dates | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ secrets.PROJECT_TOKEN }} | |
| script: | | |
| const octokit = github; | |
| const projectNumber = 4; | |
| const orgLogin = 'ArmDeveloperEcosystem'; | |
| const prNumber = context.payload.pull_request.number; | |
| const labelName = context.payload.label.name; | |
| async function getProjectItemForPR() { | |
| const projectQuery = ` | |
| query { | |
| organization(login: "${orgLogin}") { | |
| projectV2(number: ${projectNumber}) { | |
| id | |
| } | |
| } | |
| } | |
| `; | |
| const projectResponse = await octokit.graphql(projectQuery); | |
| const project = projectResponse.organization?.projectV2; | |
| if (!project) throw new Error("Project not found for organization."); | |
| const projectId = project.id; | |
| let cursor = null; | |
| let itemId = null; | |
| do { | |
| const prQuery = ` | |
| query($after: String) { | |
| organization(login: "${orgLogin}") { | |
| projectV2(number: ${projectNumber}) { | |
| items(first: 100, after: $after) { | |
| nodes { | |
| id | |
| content { | |
| ... on PullRequest { | |
| number | |
| repository { | |
| name | |
| } | |
| } | |
| } | |
| } | |
| pageInfo { | |
| hasNextPage | |
| endCursor | |
| } | |
| } | |
| } | |
| } | |
| } | |
| `; | |
| const prResponse = await octokit.graphql(prQuery, { after: cursor }); | |
| const items = prResponse.organization.projectV2.items.nodes; | |
| const foundItem = items.find(item => | |
| item.content && | |
| item.content.number === prNumber && | |
| item.content.repository.name === context.repo.repo | |
| ); | |
| if (foundItem) { | |
| itemId = foundItem.id; | |
| break; | |
| } | |
| cursor = prResponse.organization.projectV2.items.pageInfo.endCursor; | |
| } while (cursor); | |
| return { projectId, itemId }; | |
| } | |
| async function getFieldId(projectId, fieldName) { | |
| const fieldsQuery = ` | |
| query { | |
| node(id: "${projectId}") { | |
| ... on ProjectV2 { | |
| fields(first: 50) { | |
| nodes { | |
| ... on ProjectV2Field { | |
| id | |
| name | |
| dataType | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| `; | |
| const fieldsResponse = await octokit.graphql(fieldsQuery); | |
| const fields = fieldsResponse.node?.fields?.nodes || []; | |
| const field = fields.find(f => f.name === fieldName && f.dataType === 'DATE'); | |
| return field ? field.id : null; | |
| } | |
| async function updateDateField(projectId, itemId, fieldId, date) { | |
| const mutation = ` | |
| mutation { | |
| updateProjectV2ItemFieldValue( | |
| input: { | |
| projectId: "${projectId}" | |
| itemId: "${itemId}" | |
| fieldId: "${fieldId}" | |
| value: { date: "${date}" } | |
| } | |
| ) { | |
| projectV2Item { | |
| id | |
| } | |
| } | |
| } | |
| `; | |
| const result = await octokit.graphql(mutation); | |
| console.log('Mutation result:', result); | |
| return result; | |
| } | |
| async function main() { | |
| try { | |
| const { projectId, itemId } = await getProjectItemForPR(); | |
| if (!itemId) { | |
| console.log('PR not found in project board'); | |
| return; | |
| } | |
| const today = new Date().toISOString().split('T')[0]; | |
| if (labelName === 'awaiting_tech_review') { | |
| const startDateFieldId = await getFieldId(projectId, 'Start Date'); | |
| if (startDateFieldId) { | |
| await updateDateField(projectId, itemId, startDateFieldId, today); | |
| console.log('Updated Start Date to', today); | |
| } else { | |
| console.log('Start Date field not found'); | |
| } | |
| } else if (labelName === 'publish') { | |
| // Publish Date | |
| const publishDateFieldId = await getFieldId(projectId, 'Publish Date'); | |
| if (publishDateFieldId) { | |
| await updateDateField(projectId, itemId, publishDateFieldId, today); | |
| console.log('Updated Publish Date to', today); | |
| } else { | |
| console.log('Publish Date field not found'); | |
| } | |
| // Last Reviewed Date (same as Publish Date) | |
| const lastReviewedFieldId = await getFieldId(projectId, 'Last Reviewed Date'); | |
| if (lastReviewedFieldId) { | |
| await updateDateField(projectId, itemId, lastReviewedFieldId, today); | |
| console.log('Updated Last Reviewed Date to', today); | |
| } else { | |
| console.log('Last Reviewed Date field not found'); | |
| } | |
| } else { | |
| console.log('No action taken for label:', labelName); | |
| } | |
| } catch (error) { | |
| console.error('Error updating project board:', error); | |
| core.setFailed(`Error updating project board: ${error.message}`); | |
| } | |
| } | |
| main(); |