Skip to content

Commit

Permalink
Merge pull request #1 from suzuki-shunsuke/feat/first-pr
Browse files Browse the repository at this point in the history
feat: implement basic function
  • Loading branch information
suzuki-shunsuke committed Aug 11, 2022
2 parents a41167a + 329cea3 commit 52df9a6
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/workflows/renovate-config-validator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: renovate-config-validator

on:
pull_request:
branches:
- main
paths:
- .github/workflows/renovate-config-validator.yaml
- renovate.json
push:
branches:
- main
paths:
- .github/workflows/renovate-config-validator.yaml
- renovate.json

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: suzuki-shunsuke/github-action-renovate-config-validator@v0.1.2
33 changes: 33 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: test
on:
pull_request:
branches: [main]
env:
AQUA_LOG_COLOR: always
jobs:
ci-info:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: aquaproj/aqua-installer@v1.1.1
with:
aqua_version: v1.19.1
env:
GITHUB_TOKEN: ${{ github.token }}
- uses: ./store
env:
GITHUB_TOKEN: ${{ github.token }}

test:
needs: ci-info
strategy:
matrix:
env:
- runs-on: windows-latest
- runs-on: ubuntu-latest
runs-on: ${{ matrix.env.runs-on }}
steps:
- uses: actions/checkout@v3
- uses: ./restore
- run: echo "$CI_INFO_PR_NUMBER"
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,58 @@
# ci-info-action
GitHub Actiions for ci-info

GitHub Actiions for [ci-info](https://github.com/suzuki-shunsuke/ci-info).
This is useful to decrease GitHub API call by caching ci-info result.

ci-info-action has two actions.

* [store](store): Run ci-info and save the result as an artifact
* [restore](restore): Restore ci-info result from an artifact

## :warning: This action doesn't install ci-info

`store` action depends on ci-info, so you have to [install ci-info yourself](https://github.com/suzuki-shunsuke/ci-info#install).
`restore` action depends on `store` action, but doesn't depend on ci-info.

## Example

```yaml
jobs:
ci-info:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# Install ci-info with aqua
- uses: aquaproj/aqua-installer@v1.1.1
with:
aqua_version: v1.19.1

# Run ci-info and store the result as an artifact
- uses: suzuki-shunsuke/ci-info-action/store@main
env:
GITHUB_TOKEN: ${{ github.token }}

# Refer ci-info result
- run: echo "$CI_INFO_PR_NUMBER"

test:
needs: ci-info
strategy:
matrix:
env:
- runs-on: windows-latest
- runs-on: ubuntu-latest
runs-on: ${{ matrix.env.runs-on }}
steps:
- uses: actions/checkout@v3

# Restore ci-info result from an artifact
- uses: suzuki-shunsuke/ci-info-action/restore@main

# Refer ci-info result
- run: echo "$CI_INFO_PR_NUMBER"
```

## LICENSE

[MIT](LICENSE)
8 changes: 8 additions & 0 deletions aqua.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# aqua - Declarative CLI Version Manager
# https://aquaproj.github.io/
registries:
- type: standard
ref: v3.26.0 # renovate: depName=aquaproj/aqua-registry
packages:
- name: suzuki-shunsuke/ci-info@v2.1.1
7 changes: 7 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": [
"config:base",
"github>suzuki-shunsuke/renovate-config",
"github>aquaproj/aqua-renovate-config#1.2.2"
]
}
25 changes: 25 additions & 0 deletions restore/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: restore
description: Restore ci-info result from an artifact
inputs:
cache-name:
description: 'cache name'
required: false
default: ci-info
path:
description: 'Destination path'
required: false
outputs:
download-path:
value: ${{steps.download.outputs.download-path}}
runs:
using: composite
steps:
- uses: actions/download-artifact@v3
id: download
with:
name: ${{inputs.cache-name}}
path: ${{inputs.path}}
- run: cat "$CI_INFO_TEMP_DIR/env" | sed "s|^CI_INFO_TEMP_DIR=.*$|CI_INFO_TEMP_DIR=$CI_INFO_TEMP_DIR|" >> "$GITHUB_ENV"
shell: bash
env:
CI_INFO_TEMP_DIR: ${{steps.download.outputs.download-path}}
23 changes: 23 additions & 0 deletions store/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: store
description: Run ci-info and save the result as artifact
inputs:
cache-name:
description: 'cache name'
required: false
default: ci-info
runs:
using: composite
steps:
- run: |
tempfile="$(mktemp)"
ci-info run | sed "s/^export //" > "${tempfile}"
cat "$tempfile" >> "$GITHUB_ENV"
. "$tempfile"
cp "$tempfile" "${CI_INFO_TEMP_DIR}/env"
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
- uses: actions/upload-artifact@v3
with:
name: ci-info
path: ${{env.CI_INFO_TEMP_DIR}}

0 comments on commit 52df9a6

Please sign in to comment.