The Clean Up GCP Resources job is flaky #2039
This file contains 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
# Licensed to the Apache Software Foundation (ASF) under one | |
# or more contributor license agreements. See the NOTICE file | |
# distributed with this work for additional information | |
# regarding copyright ownership. The ASF licenses this file | |
# to you under the Apache License, Version 2.0 (the | |
# "License"); you may not use this file except in compliance | |
# with the License. You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, | |
# software distributed under the License is distributed on an | |
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
# KIND, either express or implied. See the License for the | |
# specific language governing permissions and limitations | |
# under the License. | |
# To learn more about GitHub Actions in Apache Beam check the CI.md | |
name: Assign Milestone on issue close | |
on: | |
issues: | |
types: [closed] | |
jobs: | |
assign-milestone: | |
if: github.event.issue.state_reason == 'completed' | |
permissions: | |
contents: write # Needed to write milestones and write to them | |
issues: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- uses: actions/github-script@v7 | |
with: | |
script: | | |
const fs = require('fs') | |
const version = fs.readFileSync('sdks/python/apache_beam/version.py', {encoding: 'utf-8'}) | |
const versionArray = version.split('.') | |
const minorVersion = versionArray[versionArray.length-3] | |
console.log(`Beam fix version: 2.${minorVersion}.0`) | |
let milestones = await github.rest.issues.listMilestones({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'open', | |
}) | |
let filteredMilestones = milestones.data.filter(m => m.title.indexOf(`2.${minorVersion}.0`) > -1) | |
if (filteredMilestones.length > 1) { | |
throw new Exception(`Invalid milestone. More than one milestone exists for 2.${minorVersion}.0`) | |
} | |
if (filteredMilestones.length == 0) { | |
await github.rest.issues.createMilestone({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title: `2.${minorVersion}.0 Release`, | |
}); | |
milestones = await github.rest.issues.listMilestones({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'open', | |
}) | |
filteredMilestones = milestones.data.filter(m => m.title.indexOf(`2.${minorVersion}.0`) > -1) | |
} | |
const curMilestone = filteredMilestones[0] | |
const issue = await github.rest.issues.update({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
milestone: curMilestone.number, | |
}) | |
console.log(issue) |