Skip to content

Commit

Permalink
ci: test and release
Browse files Browse the repository at this point in the history
  • Loading branch information
m4s-b3n committed Apr 18, 2024
1 parent 5ab8bbc commit 925793a
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 73 deletions.
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "Ubuntu",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers-contrib/features/act:1": {},
"ghcr.io/devcontainers-contrib/features/actionlint:1": {}
}
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
123 changes: 123 additions & 0 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Test & Release

on:
workflow_dispatch:
push:

# env:
# FIELD_ID: PVTF_lADOCOJGKs4AX9CyzgPUCoI
# SELECT_FIELD_ID: PVTSSF_lADOCOJGKs4AX9CyzgPUCro
# SELECT_OPTION_ID: 4b83566e
# SELECT_COMPLEX_FIELD_ID: PVTSSF_lADOCOJGKs4AX9CyzgVbXGE
# SELECT_COMPLEX_OPTION_ID: 0a479792

permissions:
contents: write
issues: write
pull-requests: write

jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
include:
- test-name: "Get field id"
field-name: "Test Field"
selection-option-name: ""
expected-field-id: PVTF_lADOCOJGKs4AX9CyzgPUCoI
expected-secection-option-id: ""
- test-name: "Get select option id"
field-name: "Test select field"
selection-option-name: "Option1"
expected-field-id: PVTSSF_lADOCOJGKs4AX9CyzgPUCro
expected-secection-option-id: 4b83566e
- test-name: "Get Complex select option id"
field-name: "Test complex select field"
selection-option-name: "Complex Option 1"
expected-field-id: PVTSSF_lADOCOJGKs4AX9CyzgVbXGE
expected-secection-option-id: 0a479792

steps:
- name: Checkout
uses: actions/checkout@v4
with:
show-progress: false
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.TESTING_APP_ID }}
private-key: ${{ secrets.TESTING_APP_KEY }}
- name: Exec
id: get-field-id
uses: ./
with:
token: ${{ steps.app-token.outputs.token }}
project-number: 1
project-owner: infinite-automations
field-name: ${{ matrix.field-name }}
select-option-name: ${{ matrix.selection-option-name }}
- name: Test field ID
uses: nick-fields/assert-action@v2
with:
expected: ${{ matrix.expected-field-id }}
actual: ${{ steps.get-field-id.outputs.field-id }}
comparison: exact
- name: Test select option ID
uses: nick-fields/assert-action@v2
with:
expected: ${{ matrix.expected-secection-option-id }}
actual: ${{ steps.get-field-id.outputs.select-option-id }}
comparison: exact

# - name: Get select option id
# id: get-select-option-id
# uses: ./
# with:
# token: ${{ steps.app-token.outputs.token }}
# project-number: 1
# project-owner: infinite-automations
# field-name: Test select field
# select-option-name: Option1
# - name: Test Get select option id
# uses: nick-fields/assert-action@v2
# with:
# expected: ${{ env.SELECT_OPTION_ID }}
# actual: ${{ steps.get-select-option-id.outputs.select-option-id }}
# comparison: exact
# - name: Get Complex select option id
# id: get-complex-select-option-id
# uses: ./
# with:
# token: ${{ steps.app-token.outputs.token }}
# project-number: 1
# project-owner: infinite-automations
# field-name: Test complex select field
# select-option-name: Complex Option 1
# - name: Test Get complex select option id
# uses: nick-fields/assert-action@v2
# with:
# expected: ${{ env.SELECT_COMPLEX_OPTION_ID }}
# actual: ${{ steps.get-complex-select-option-id.outputs.select-option-id }}
# comparison: exact

release:
name: Release
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Semantic Release Plugins
run: |
npm install semantic-release-replace-plugin -D
npm install --save-dev semantic-release-major-tag
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
with:
dry_run: ${{ github.event_name == 'pull_request' }}
ci: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66 changes: 0 additions & 66 deletions .github/workflows/test.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"branches": [
"main"
],
"tagFormat": "v${version}",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
[
"semantic-release-major-tag",
{
"customTags": [
"v${major}",
"v${major}.${minor}"
]
}
],
[
"semantic-release-replace-plugin",
{
"replacements": [
{
"files": [
"README.md"
],
"from": "uses: infinite-automations/gh-projects-field-ids@.*",
"to": "uses: infinite-automations/gh-projects-field-ids@v${nextRelease.version}",
"results": [
{
"file": "README.md",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}
],
"countMatches": true
}
]
}
],
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
[
"@semantic-release/git",
{
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
"assets": [
"CHANGELOG.md",
"README.md"
]
}
]
]
}
34 changes: 27 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,40 @@ runs:
using: "composite"
steps:
- name: Get field id
id: get-field-id
id: get-ids
if: ${{ inputs.field-name }}
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
run: |
field_id=$(gh project field-list ${{ inputs.project-number }} --owner "${{ inputs.project-owner }}" --format json | jq -r --arg fieldName "${{ inputs.field-name }}" '.fields[] | select(.name==$fieldName) .id')
echo "id=$field_id" >> "$GITHUB_OUTPUT"
JSON=$(\
gh project field-list ${{ inputs.project-number }} \
--owner "${{ inputs.project-owner }}" \
--format json \
)
echo json="$JSON" >> "$GITHUB_OUTPUT"
- name: Get field id
id: get-field-id
if: ${{ inputs.field-name }}
shell: bash
run: |
FIELD_ID=$(\
echo '${{ steps.get-ids.outputs.json }}' \
| jq -r \
--arg fieldName "${{ inputs.field-name }}" \
'.fields[] | select(.name==$fieldName) .id' \
)
echo "id=$FIELD_ID" >> "$GITHUB_OUTPUT"
- name: Get select option id
id: get-select-option-id
if: ${{ inputs.select-option-name }}
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
run: |
field_id=$(gh project field-list ${{ inputs.project-number }} --owner "${{ inputs.project-owner }}" --format json | jq -r --arg fieldName "${{ inputs.field-name }}" --arg selectOptionName "${{ inputs.select-option-name }}" '.fields[] | select(.name==$fieldName) .options[] | select(.name==$selectOptionName) .id')
echo "id=$field_id" >> "$GITHUB_OUTPUT"
SELECTION_OPTION_ID=$(\
echo "$JSON" \
| jq -r \
--arg fieldName "${{ inputs.field-name }}" \
--arg selectOptionName "${{ inputs.select-option-name }}" \
'.fields[] | select(.name=="$fieldName") .options[] | select(.name=="$selectOptionName") .id' \
)
echo "id=$SELECTION_OPTION_ID" >> "$GITHUB_OUTPUT"

0 comments on commit 925793a

Please sign in to comment.