Slide 1

Slide 1 text

© 2023 SRE Holdings Corporation 証券コード:2980 © 2023 SRE Holdings Corporation GitHub Actions 2023/08/09 Oracle Cloud Hangout Cafe LT

Slide 2

Slide 2 text

© 2023 SRE Holdings Corporation SRE Holdings 2 2014 2019 SRE / AI DX DX IT

Slide 3

Slide 3 text

© 2023 SRE Holdings Corporation • ( @kota65535) • • ⁃ ⁃ ⁃ ⁃ CI/CD ⁃ 3

Slide 4

Slide 4 text

© 2023 SRE Holdings Corporation • Custom Actions • JavaScript • Agenda 4

Slide 5

Slide 5 text

© 2023 SRE Holdings Corporation Custom Action

Slide 6

Slide 6 text

© 2023 SRE Holdings Corporation • • ⁃ ⁃ ⁃ ⁃ Custom Actions 6

Slide 7

Slide 7 text

© 2023 SRE Holdings Corporation • JavaScript ⁃ Runner Node.js JavaScript ⁃ : https://github.com/actions/hello-world-javascript-action • Docker ⁃ Runner Docker ⁃ ⁃ : https://github.com/actions/hello-world-docker-action • Composite ⁃ ⁃ : https://github.com/microsoft/action-python 7

Slide 8

Slide 8 text

© 2023 SRE Holdings Corporation JavaScript

Slide 9

Slide 9 text

© 2023 SRE Holdings Corporation • Minimal • https://github.com/kota65535/hello-world-javascript-action Minimal JavaScript 9 . ├── README.md ├── action.yml ├── index.js ├── node_modules ├── package-lock.json └── package.json ⁃ action.yml • ⁃ index.js • JavaScript ⁃ node_modules • NPM node_modules ⁃ package.json & package-lock.json • NPM package.json

Slide 10

Slide 10 text

© 2023 SRE Holdings Corporation • • ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ action.yml 10

Slide 11

Slide 11 text

© 2023 SRE Holdings Corporation • inputs ⁃ Map ⁃ ⁃ or not • outputs ⁃ Map • runs ⁃ ⁃ ⁃ JavaScript • using : Node • main : action.yml 11 inputs: who-to-greet: description: 'Who to greet' required: true default: 'World' outputs: time: description: 'The time we greeted you' runs: using: 'node16' main: 'index.js'

Slide 12

Slide 12 text

© 2023 SRE Holdings Corporation • JavaScript • @actions/core ⁃ JavaScript ⁃ index.js 12 const core = require('@actions/core'); try { // const nameToGreet = core.getInput('who-to-greet'); // core.info(`Hello ${nameToGreet}!`); ...

Slide 13

Slide 13 text

© 2023 SRE Holdings Corporation index.js 13 try { // const nameToGreet = core.getInput('who-to-greet'); // core.info(`Hello ${nameToGreet}!`); // const time = (new Date()).toTimeString(); // core.setOutput("time", time); } catch (error) { // Fail core.setFailed(error.message); }

Slide 14

Slide 14 text

© 2023 SRE Holdings Corporation • • @actions/core • ⁃ @actions/github Octokit GitHub API package.json & package-lock.json 14 // Octokit const octokit = getOctokit(token); // Issue await octokit.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, "LGTM!" });

Slide 15

Slide 15 text

© 2023 SRE Holdings Corporation • index.js • ⁃ node_modules Commit ⁃ ncc Bundle Commit • husky pre-commit • TypeScript • https://github.com/actions/typescript-action node_modules 15

Slide 16

Slide 16 text

© 2023 SRE Holdings Corporation • https://github.com/kota65535/hello-world-javascript-action-test • 16 steps: - name: Checkout uses: actions/checkout@v3 - name: Greet uses: kota65535/hello-world-javascript-action@main with: who-to-greet: foo

Slide 17

Slide 17 text

© 2023 SRE Holdings Corporation 17

Slide 18

Slide 18 text

© 2023 SRE Holdings Corporation &

Slide 19

Slide 19 text

© 2023 SRE Holdings Corporation • Semantic Versioning : v1.2.3 • v1 • • Release 19 name: Release on: workflow_dispatch: inputs: version: description: Released version type: string required: true ...

Slide 20

Slide 20 text

© 2023 SRE Holdings Corporation Release 20 jobs: release: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Configure git uses: kota65535/github-git-config-action@v1 with: user.name: Tomohiko Ozawa user.email: [email protected] - name: Get major version run: echo "MAJOR_VERSION=$(perl -ne 'print $1 if /^(.*?)\.(.*?)\.(.*?)$/' <<< '${{ inputs.version }}')" >> $GITHUB_ENV - name: Run npm version run: npm version ${{ inputs.version }} - name: Update the major version tag run: git tag -f v${{ env.MAJOR_VERSION }} - name: Push the version commit and tags run: | git pull --rebase --autostash git push origin HEAD git push -f --tags

Slide 21

Slide 21 text

© 2023 SRE Holdings Corporation • Release 21 main v1.2.4 v1 v1 v1.2.3

Slide 22

Slide 22 text

© 2023 SRE Holdings Corporation • GitHub Marketplace • ⁃ ⁃ GitHub Marketplace 22

Slide 23

Slide 23 text

© 2023 SRE Holdings Corporation • name ⁃ ⁃ • description ⁃ • branding ⁃ ⁃ icon • Feather ⁃ color • action.yml 23 name: "Terraform Plan to PR Comment" description: "Notify Terraform plan result as a pull request comment" branding: icon: "cloud" color: "purple"

Slide 24

Slide 24 text

© 2023 SRE Holdings Corporation • action.yml • Publish this Action to the GitHub Marketplace 24

Slide 25

Slide 25 text

© 2023 SRE Holdings Corporation • ⁃ : Continuous Integration, Security, Utilities, Chat • Publish release GitHub Marketplace 25

Slide 26

Slide 26 text

© 2023 SRE Holdings Corporation • 26

Slide 27

Slide 27 text

© 2023 SRE Holdings Corporation Custom Action CI/CD

Slide 28

Slide 28 text

© 2023 SRE Holdings Corporation