diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8f7dd8a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +[*.{cmd,bat}] +end_of_line = crlf diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..311f1fb --- /dev/null +++ b/.gitattributes @@ -0,0 +1,16 @@ +# Set default behavior to automatically normalize line endings. +* text=auto eol=lf + +# Force batch scripts to always use CRLF line endings so that if a repo is accessed +# in Windows via a file share from Linux, the scripts will work. +*.{cmd,[cC][mM][dD]} text eol=crlf +*.{bat,[bB][aA][tT]} text eol=crlf + +# Force bash scripts to always use LF line endings so that if a repo is accessed +# in Unix via a file share from Windows, the scripts will work. +*.sh text eol=lf + +# Common files config +*.jpg -text +*.png -text +*.pdf -text diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..a1fbf8f --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# Default reviewers/codeowners for all code changes in the repository +* @DariuszPorowski diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..8b1edf7 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,83 @@ +# 🔰 Contributor Covenant Code of Conduct + +## 🤝 Our Pledge + +We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. + +## ✅ Our Standards + +Examples of behavior that contributes to a positive environment for our community include: + +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience +- Focusing on what's best not just for us as individuals, but for the overall community + +Examples of unacceptable behavior include: + +- The use of sexualized language or imagery, and sexual attention or advances of any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a professional setting + +## 📝 Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. + +## 🔭 Scope + +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. + +## 🚓 Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [Twitter message](https://twitter.com/DariuszPorowski). All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the reporter of any incident. + +## 🛂 Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of actions. + +**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the community. + +## 🔗 Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..043ecd4 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,25 @@ +# 👥 Contributing Guide + +I appreciate your interest in contributing to the project! This document outlines how to contribute to the project, including the contribution process, code style, and testing. + +## 🔄️ Contribution process + +To contribute, please follow these steps: + +1. Fork the project name repository on GitHub. +1. Create a new branch for your feature or bug fix. +1. Make sure the `README.md` and any other relevant documentation are kept up-to-date. +1. Make your changes and commit them with descriptive commit messages; check [Conventional Commits](https://www.conventionalcommits.org) as a suggestion. +1. Push to your forked repository. +1. Create a new pull request from your fork to this project. +1. Please ensure that your pull request includes a detailed description of your changes and that your code adheres to the code style guidelines outlined below. + +## 🔰 Code of Conduct + +All contributors are expected to adhere to the project name code of conduct. Therefore, please review it before contributing [`Code of Conduct`](./CODE_OF_CONDUCT.md). + +## 📄 License + +By contributing to this project, you agree that your contributions will be licensed under the project license. + +Thank you for contributing! diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..0d362cb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,88 @@ +--- +# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema +name: 🐛 Bug Report +description: If something isn't working 🔧 +title: "🐛 [bug]: " +labels: [bug] +body: + - type: markdown + attributes: + value: Thanks for taking the time to fill out this bug report! + - type: textarea + id: what-happened + attributes: + label: 🐛 What happened? + description: A clear and concise description of what the bug is. + placeholder: Describe what happened + validations: + required: true + - type: textarea + id: reproduce + attributes: + label: 🔬 How to reproduce? + description: Steps to reproduce the behavior. + placeholder: | + 1. ... + 2. ... + validations: + required: false + - type: textarea + id: code-sample + attributes: + label: 🏗️ Code Sample / Log + description: Please copy and paste any relevant code sample / log output. + render: Shell + placeholder: This will be automatically formatted into code, so no need for backticks. + validations: + required: false + - type: input + id: dump-contexts-action + attributes: + label: 🌌 Environment (Dump Contexts Action) + description: What Dump Contexts Action version are you running? + placeholder: 1.0.0 + validations: + required: true + - type: dropdown + id: os + attributes: + label: 🌌 Environment (GitHub Runner OS) + description: What OS are you running? + options: + - Linux + - Windows + - macOS + validations: + required: true + - type: textarea + id: screenshots + attributes: + label: 📷 Screenshots + description: If applicable, add screenshots to help explain your problem. + placeholder: Just do Ctrl+V having screenshot in the clipboard. + validations: + required: false + - type: textarea + id: expected-behavior + attributes: + label: 📈 Expected behavior + description: A clear and concise description of what you expected to happen. + placeholder: A clear and concise description of what you expected to happen. + validations: + required: false + - type: textarea + id: additional-context + attributes: + label: 📎 Additional context + description: Add any other context about the problem here. + placeholder: Add any other context about the problem here. + validations: + required: false + - type: checkboxes + id: terms + attributes: + label: 📜 Code of Conduct + description: By submitting this issue, you agree to follow our [`Code of Conduct`](https://github.com/DariuszPorowski/ghaction-dump-contexts/blob/main/.github/CODE_OF_CONDUCT.md) + options: + - label: I agree to follow this project's Code of Conduct. + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..04a1787 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,2 @@ +# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser +blank_issues_enabled: false diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml new file mode 100644 index 0000000..fe23254 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -0,0 +1,50 @@ +--- +# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema +name: 🚀 Feature request +description: Suggest an idea for this project 🏖 +title: "🚀 [feature]: " +labels: [enhancement] +body: + - type: markdown + attributes: + value: Thanks for taking the time to fill out this new feature idea! + - type: textarea + id: description + attributes: + label: 🚀 Feature description + description: A clear and concise description of the feature proposal. + placeholder: A clear and concise description of the feature proposal. + validations: + required: true + - type: textarea + id: motivation + attributes: + label: 🔈 Motivation + description: Please describe the motivation for this proposal. + placeholder: Please describe the motivation for this proposal. + validations: + required: false + - type: textarea + id: alternatives + attributes: + label: 🛰 Alternatives + description: A clear and concise description of any alternative solutions or features you've considered. + placeholder: A clear and concise description of any alternative solutions or features you've considered. + validations: + required: false + - type: textarea + id: additional-context + attributes: + label: 📎 Additional context + description: Add any other context or screenshots about the feature request here. + placeholder: Add any other context or screenshots about the feature request here. + validations: + required: false + - type: checkboxes + id: terms + attributes: + label: 📜 Code of Conduct + description: By submitting this issue, you agree to follow our [`Code of Conduct`](https://github.com/DariuszPorowski/ghaction-dump-contexts/blob/main/.github/CODE_OF_CONDUCT.md) + options: + - label: I agree to follow this project's Code of Conduct. + required: true diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml new file mode 100644 index 0000000..f03cbfb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -0,0 +1,44 @@ +--- +# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema +name: ❓ Question +description: Ask a question about this project 🎓 +title: "❓ [question]: " +labels: [question] +body: + - type: markdown + attributes: + value: Thanks for taking the time to fill out this new feature idea! + - type: checkboxes + id: checklist + attributes: + label: ✅ Checklist + description: Mark with an ✔️ all the checkboxes that apply. + options: + - label: I've searched the project's [`issues`](https://github.com/DariuszPorowski/ghaction-dump-contexts/issues?q=is%3Aissue) and did not find answer for my question. + required: true + - type: textarea + id: question + attributes: + label: ❓ Question + description: What is your question? + placeholder: | + How can I ...? + Is it possible to ...? + validations: + required: true + - type: textarea + id: additional-context + attributes: + label: 📎 Additional context + description: Add any other context or screenshots about the question here. + placeholder: Add any other context or screenshots about the question here. + validations: + required: false + - type: checkboxes + id: terms + attributes: + label: 📜 Code of Conduct + description: By submitting this issue, you agree to follow our [`Code of Conduct`](https://github.com/DariuszPorowski/ghaction-dump-contexts/blob/main/.github/CODE_OF_CONDUCT.md) + options: + - label: I agree to follow this project's Code of Conduct. + required: true diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..56a351c --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,27 @@ +## 💌 Description + + + +## 🔗 Related issue + + +Fixes: # + +## 🏗️ Type of change + + + +- [ ] 📚 Examples / docs / tutorials / dependencies update +- [ ] 🐛 Bug fix (non-breaking change which fixes an issue) +- [ ] 🥂 Improvement (non-breaking change which improves an existing feature) +- [ ] 🚀 New feature (non-breaking change which adds functionality) +- [ ] 💥 Breaking change (fix or feature that would cause existing functionality to change) +- [ ] 🚨 Security fix +- [ ] ⬆️ Dependencies update + +## ✅ Checklist + + + +- [ ] I've read the [`Code of Conduct`](https://github.com/DariuszPorowski/ghaction-dump-contexts/blob/main/.github/CODE_OF_CONDUCT.md) document. +- [ ] I've read the [`Contributing`](https://github.com/DariuszPorowski/ghaction-dump-contexts/blob/main/.github/CONTRIBUTING.md) guide. diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..9b91d90 --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,31 @@ +# 🔐 Security Policy + +## 🎯 Supported Versions + +| Version | Supported | +|:-------:|:---------:| +| 1.x.x | ✅ | + +## 🚨 Reporting a Vulnerability + +If you believe you have found a security vulnerability in the project, please do not hesitate to report it to us. We take all security issues seriously and will do our best to address them promptly. + +To report a security vulnerability, please send a [Twitter message](https://twitter.com/DariuszPorowski) describing the vulnerability. In addition, please include any relevant information that could help us reproduce the issue, such as steps to reproduce the vulnerability, the affected versions of the software, and any other relevant details. + +We will acknowledge receipt of your report within 2 business days and work with you to verify the vulnerability and develop a fix. We may also ask you for additional information or clarifications as needed. + +## ⏳ Response Time + +We strive to address security issues as quickly as possible. Our response time depends on the severity of the issue, but we will do our best to provide a fix or a workaround within one week of receiving a vulnerability report. In some cases, it may take longer to address a security issue, but we will keep you updated on our progress. + +## 👁️ Disclosure Policy + +We will disclose security vulnerabilities in our project as soon as we have verified them and developed a fix or a workaround. We will notify users of the vulnerability via our GitHub repository and other appropriate channels. + +## 📜 Code of Conduct + +All participants in our project are expected to adhere to our [`Code of Conduct`](https://github.com/DariuszPorowski/ghaction-dump-contexts/blob/main/.github/CODE_OF_CONDUCT.md). Furthermore, we expect everyone to treat each other respectfully and contribute to a positive and inclusive community. + +## ✉️ Contact + +If you have any questions or concerns about our security policy, don't hesitate to contact us using [Twitter message](https://twitter.com/DariuszPorowski). diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5dafeae --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily + commit-message: + prefix: "[github-actions] :arrow_up: " diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..90c87ed --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,79 @@ +--- +name-template: v$RESOLVED_VERSION +tag-template: v$RESOLVED_VERSION +footer: | + + See details of all code changes: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION since previous release. +template: | + ## 🔄️ What's Changed + + $CHANGES + + ## 👥 Contributors + + $CONTRIBUTORS + +categories: + - title: 💥 Breaking + labels: + - major + - breaking + - title: 🚀 Features + labels: + - minor + - feature + - enhancement + - title: 🐛 Bug Fixes + labels: + - fix + - bugfix + - bug + - title: 🧰 Maintenance + labels: + - maintenance + - chore + - title: 📚 Documentation + labels: + - doc + - docs + - documentation + - title: Other changes + label: patch + - title: ⬆️ Dependencies + labels: + - dependencies + - deps + collapse-after: 3 + - title: 🚨 Security + label: security + collapse-after: 3 +exclude-labels: + - skip-changelog +change-template: "- $TITLE @$AUTHOR (#$NUMBER)" +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +version-resolver: + major: + labels: + - major + - breaking + minor: + labels: + - minor + - feature + - enhancement + patch: + labels: + - patch + - fix + - bugfix + - bug + - maintenance + - chore + - doc + - docs + - documentation + - deps + - dependencies + - security + default: patch +# TODO autolabeler https://github.com/release-drafter/release-drafter/#autolabeler diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..dc90e5a --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,17 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - security +# Label to use when marking an issue as stale +staleLabel: wontfix +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..285e9fb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,95 @@ +--- +name: CI + +on: + pull_request: + push: + workflow_dispatch: + inputs: + lorem-ipsum: + type: choice + description: Lorem ipsum + required: true + options: + - foo + - bar + default: foo + +# Allow one concurrent +concurrency: + group: ${{ format('{0}-{1}', github.event_name, github.ref) }} + cancel-in-progress: true + +env: + FOO: BAR + DEBUG: ${{ secrets.ACTIONS_RUNNER_DEBUG || vars.ACTIONS_RUNNER_DEBUG || secrets.ACTIONS_STEP_DEBUG || vars.ACTIONS_STEP_DEBUG || false }} + +jobs: + lint: + name: Lint + if: ${{ github.event_name == 'pull_request' }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: actionlint + uses: DariuszPorowski/actionlint-action@v1 + with: + flags: "-ignore SC2086" + + - name: Run pre-commit + run: | + pip install pre-commit + pre-commit run --all-files --verbose + + dog-food-matrix: + name: Dog food (test runners) + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Dump Contexts Action + uses: ./ + with: + vars-context: ${{ toJson(vars) }} + secrets-context: ${{ toJson(secrets) }} + needs-context: ${{ toJson(needs) }} + inputs-context: ${{ toJson(inputs) }} + + dog-food: + name: Dog food (test inputs) + needs: + - dog-food-matrix + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Dump Contexts Action (inputs) + uses: ./ + with: + vars-context: ${{ toJson(vars) }} + secrets-context: ${{ toJson(secrets) }} + needs-context: ${{ toJson(needs) }} + inputs-context: ${{ toJson(inputs) }} + + - name: Dump Contexts Action (no inputs) + uses: ./ + + - name: Dump Contexts Action (only debug) + if: ${{ env.DEBUG }} + uses: ./ + with: + vars-context: ${{ toJson(vars) }} + secrets-context: ${{ toJson(secrets) }} + needs-context: ${{ toJson(needs) }} + inputs-context: ${{ toJson(inputs) }} diff --git a/.github/workflows/release.draft.yml b/.github/workflows/release.draft.yml new file mode 100644 index 0000000..2c78b74 --- /dev/null +++ b/.github/workflows/release.draft.yml @@ -0,0 +1,44 @@ +--- +name: Draft Release + +on: + push: + branches: + - main + workflow_dispatch: + # pull_request: + # # Only following types are handled by the action, but one can default to all as well + +permissions: {} + +jobs: + draft-release: + if: ${{ github.repository_owner == 'DariuszPorowski' }} + name: Draft Release + permissions: + contents: write + pull-requests: read + runs-on: ubuntu-latest + steps: + - name: Dump Contexts + uses: DariuszPorowski/ghaction-dump-contexts@main + with: + vars-context: ${{ toJson(vars) }} + secrets-context: ${{ toJson(secrets) }} + needs-context: ${{ toJson(needs) }} + inputs-context: ${{ toJson(inputs) }} + + - name: Run Release Drafter + uses: release-drafter/release-drafter@v5 + id: release-drafter + with: + prerelease: true + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Get Release URL + run: | + echo "${RELEASE_URL}" + echo "${RELEASE_URL}" >> $GITHUB_STEP_SUMMARY + env: + RELEASE_URL: ${{ steps.release-drafter.outputs.html_url }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e1b803f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +--- +name: Release + +on: + # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release + release: + types: + - published + workflow_dispatch: + inputs: + tag-name: + description: Tag name that the major tag will point to + required: true + +env: + TAG_NAME: ${{ github.event.inputs.tag-name || github.event.release.tag_name }} + +jobs: + gh-release-update: + name: GitHub Release + environment: + name: Release + url: ${{ steps.gh-release.outputs.url }} + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Dump Contexts + uses: DariuszPorowski/ghaction-dump-contexts@main + with: + vars-context: ${{ toJson(vars) }} + secrets-context: ${{ toJson(secrets) }} + needs-context: ${{ toJson(needs) }} + inputs-context: ${{ toJson(inputs) }} + + - name: Update release to the latest + id: gh-release + uses: softprops/action-gh-release@v1 + with: + prerelease: false + + - name: Update the major tag to include the ${{ env.TAG_NAME }} changes + id: update-major-tag + uses: actions/publish-action@v0.2.2 + with: + source-tag: ${{ env.TAG_NAME }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0a6b72e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +package.json +package-lock.json +dev.js diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..6ff639a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +default_install_hook_types: + - pre-commit +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: check-case-conflict + - id: check-yaml + - id: end-of-file-fixer + # - id: no-commit-to-branch + - id: trailing-whitespace + + - repo: https://github.com/gitleaks/gitleaks + rev: v8.16.3 + hooks: + - id: gitleaks + + - repo: https://github.com/rhysd/actionlint + rev: v1.6.24 + hooks: + - id: actionlint + args: + - "-ignore" + - "SC2086" diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0c341a2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,30 @@ +{ + // git + "git.autorefresh": true, + "git.autofetch": true, + "git.fetchOnPull": true, + "git.pruneOnFetch": true, + "git.branchProtection": [ + "main", + "master", + ], + // files + "files.trimTrailingWhitespace": true, + "files.insertFinalNewline": true, + "files.associations": { + "CODEOWNERS": "ignore", + }, + // editor + "editor.formatOnSave": true, + // markdown + "[markdown]": { + "editor.formatOnSave": true, + "editor.formatOnPaste": true + }, + "markdown.extension.toc.levels": "2..6", + "markdown.extension.toc.unorderedList.marker": "-", + "markdown.extension.toc.updateOnSave": true, + "markdown.extension.orderedList.marker": "one", + "markdown.extension.print.absoluteImgPath": true, + "markdown.extension.toc.slugifyMode": "github" +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6adde1a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Dariusz Porowski + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index f395431..a64bd56 100644 --- a/README.md +++ b/README.md @@ -1 +1,87 @@ -# Readme +# 🩺 Dump Contexts Action + +[![GitHub - marketplace](https://img.shields.io/badge/marketplace-dump--contexts-blue?logo=github&style=flat-square)](https://github.com/marketplace/actions/dump-contexts) +[![GitHub - release](https://img.shields.io/github/v/release/DariuszPorowski/ghaction-dump-contexts?style=flat-square)](https://github.com/DariuszPorowski/ghaction-dump-contexts/releases/latest) +[![GitHub - ci](https://img.shields.io/github/actions/workflow/status/DariuszPorowski/ghaction-dump-contexts/ci.yml?logo=github&label=CI&style=flat-square&branch=main&event=push)](https://github.com/DariuszPorowski/ghaction-dump-contexts/actions/workflows/ci.yml?query=branch%3Amain+event%3Apush) +[![GitHub - license](https://img.shields.io/github/license/DariuszPorowski/ghaction-dump-contexts?style=flat-square)](https://github.com/DariuszPorowski/ghaction-dump-contexts/blob/main/LICENSE) + +This action allows you to quickly and easily dump [GitHub contexts](https://docs.github.com/en/actions/learn-github-actions/contexts) and Runner environment, giving you a comprehensive overview of the current state of your GitHub workflow. This can be useful for GitHub workflows development, troubleshooting, debugging, or understanding how different components interact with each other. + +- Action is platform-independent. +- The output of each dump is in the `JSON` format as much as possible. + +![demo](https://raw.githubusercontent.com/DariuszPorowski/ghaction-dump-contexts/main/assets/images/demo.png) + +## Table of Contents + +- [🤔 Usage](#-usage) + - [Quick Start](#quick-start) + - [Extra context](#extra-context) + - [Run only when `GitHub debug logging` enabled](#run-only-when-github-debug-logging-enabled) +- [📥 Inputs](#-inputs) +- [👥 Contributing](#-contributing) +- [📄 License](#-license) + +## 🤔 Usage + +### Quick Start + +Just place in your GitHub workflow steps: + +```yaml +- name: Dump Contexts + uses: DariuszPorowski/ghaction-dump-contexts@v1 +``` + +### Extra context + +By default, [composite](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action) action cannot access contexts like `vars`, `secrets` `needs`, `inputs`. So if you want to include them in the dump, you must specify them explicitly. For more details, follow [📥 Inputs](#-inputs) section. + +```yaml +- name: Dump Contexts + uses: DariuszPorowski/ghaction-dump-contexts@v1 + with: + vars-context: ${{ toJson(vars) }} # optional + secrets-context: ${{ toJson(secrets) }} # optional + needs-context: ${{ toJson(needs) }} # optional + inputs-context: ${{ toJson(inputs) }} # optional +``` + +### Run only when `GitHub debug logging` enabled + +In certain circumstances (e.g., re-run failing workflow), if you'd like to run `Dump Contexts Action` only when [GitHub debug logging](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging) is enabled, then set `env` on workflow or job level: + +```yaml +env: + DEBUG: ${{ secrets.ACTIONS_RUNNER_DEBUG || vars.ACTIONS_RUNNER_DEBUG || secrets.ACTIONS_STEP_DEBUG || vars.ACTIONS_STEP_DEBUG || false }} +``` + +and add `if: ${{ env.DEBUG }}` condition to the action. + +```yaml +- name: Dump Contexts + if: ${{ env.DEBUG }} + uses: DariuszPorowski/ghaction-dump-contexts@v1 + with: + vars-context: ${{ toJson(vars) }} # optional + secrets-context: ${{ toJson(secrets) }} # optional + needs-context: ${{ toJson(needs) }} # optional + inputs-context: ${{ toJson(inputs) }} # optional +``` + +## 📥 Inputs + +| Name | Required | Type | Default value | Description | +|-----------------|----------|---------------|---------------|-----------------------------------------------------------------------------------------------------------| +| vars-context | false | `json object` | *not set* | The context for the `vars` must be explicitly provided, as it is unavailable in the composite actions. | +| secrets-context | false | `json object` | *not set* | The context for the `secrets` must be explicitly provided, as it is unavailable in the composite actions. | +| needs-context | false | `json object` | *not set* | The context for the `needs` must be explicitly provided, as it is unavailable in the composite actions. | +| inputs-context | false | `json object` | *not set* | The context for the `inputs` must be explicitly provided, as it is unavailable in the composite actions. | + +## 👥 Contributing + +Contributions to the project are welcome! Please follow [Contributing Guide](https://github.com/DariuszPorowski/ghaction-dump-contexts/blob/main/.github/CONTRIBUTING.md). + +## 📄 License + +This project is distributed under the terms of the [MIT](https://github.com/DariuszPorowski/ghaction-dump-contexts/blob/main/LICENSE) license. diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..b1e1b59 --- /dev/null +++ b/action.yml @@ -0,0 +1,240 @@ +# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions +name: Dump Contexts +description: Dump GitHub contexts and Runner environment +author: Dariusz Porowski +branding: + icon: info # https://feathericons.com + color: blue + +inputs: + vars-context: + description: vars context + required: false + default: ${{ null }} + secrets-context: + description: secrets context + required: false + default: ${{ null }} + needs-context: + description: needs context + required: false + default: ${{ null }} + inputs-context: + description: inputs context + required: false + default: ${{ null }} + +runs: + using: composite + steps: + - uses: actions/github-script@v6 + if: ${{ always() }} + with: + script: | + // dependencies + const fs = require('fs') + + // constraints + const color = '\x1b[34m' // blue + const reset = '\x1b[0m' + const emoji = '⬇️' + const expand = 'expand for details' + const platform = process.platform + + // helpers + function groupHeader (group) { + return `${color}${emoji} ${group}${reset} ${expand}` + } + + function jsonLogOutput (jsonObj, parse = true) { + const jsonObjParsed = parse ? JSON.parse(jsonObj) : jsonObj + return JSON.stringify(jsonObjParsed, null, 2) + } + + // os env vars + await core.group(groupHeader('OS (environment variables)'), async () => { + const envVars = {} + Object.keys(process.env) + .filter(key => !key.startsWith('INPUT_') && !key.startsWith('ACTION_DUMP_')) + .sort() + .forEach(key => { + envVars[key] = process.env[key] + }) + core.info(jsonLogOutput(envVars, false)) + }) + + // github context + await core.group(groupHeader('GitHub (github context)'), async () => { + core.info(jsonLogOutput(process.env.ACTION_DUMP_CONTEXT_GITHUB)) + }) + + // env context + await core.group(groupHeader('GitHub (env context)'), async () => { + core.info(jsonLogOutput(process.env.ACTION_DUMP_CONTEXT_ENV)) + }) + + // vars context + const varsContext = process.env.ACTION_DUMP_CONTEXT_VARS + if (varsContext !== '') { + await core.group(groupHeader('GitHub (vars context)'), async () => { + core.info(jsonLogOutput(varsContext)) + }) + } + + // job context + await core.group(groupHeader('GitHub (job context)'), async () => { + core.info(jsonLogOutput(process.env.ACTION_DUMP_CONTEXT_JOB)) + }) + + // steps context + await core.group(groupHeader('GitHub (steps context)'), async () => { + core.info(jsonLogOutput(process.env.ACTION_DUMP_CONTEXT_STEPS)) + }) + + // runner context + await core.group(groupHeader('GitHub (runner context)'), async () => { + core.info(jsonLogOutput(process.env.ACTION_DUMP_CONTEXT_RUNNER)) + }) + + // secrets context + const secretsContext = process.env.ACTION_DUMP_CONTEXT_SECRETS + if (secretsContext !== '') { + await core.group(groupHeader('GitHub (secrets context)'), async () => { + core.info(jsonLogOutput(secretsContext)) + }) + } + + // strategy context + await core.group(groupHeader('GitHub (strategy context)'), async () => { + core.info(jsonLogOutput(process.env.ACTION_DUMP_CONTEXT_STRATEGY)) + }) + + // matrix context + await core.group(groupHeader('GitHub (matrix context)'), async () => { + core.info(jsonLogOutput(process.env.ACTION_DUMP_CONTEXT_MATRIX)) + }) + + // needs context + const needsContext = process.env.ACTION_DUMP_CONTEXT_NEEDS + if (needsContext !== '') { + await core.group(groupHeader('GitHub (needs context)'), async () => { + core.info(jsonLogOutput(needsContext)) + }) + } + + // inputs context + const inputsContext = process.env.ACTION_DUMP_CONTEXT_INPUTS + if (inputsContext !== '') { + await core.group(groupHeader('GitHub (inputs context)'), async () => { + core.info(jsonLogOutput(inputsContext)) + }) + } + + // event file + await core.group(groupHeader('GitHub (event file)'), async () => { + core.info(`path: ${process.env.GITHUB_EVENT_PATH}`) + core.info(jsonLogOutput(fs.readFileSync(process.env.GITHUB_EVENT_PATH, { encoding: 'utf-8' }).trim())) + }) + + // docker + let dockerBinary = 'docker' + if (platform === 'win32') { + dockerBinary = 'docker.exe' + } + + let dockerExists = false + try { + await io.which(dockerBinary, true) + dockerExists = true + } catch (err) { + dockerExists = false + } + + if (dockerExists) { + // docker version + await core.group(groupHeader('Docker (version)'), async () => { + const { stdout } = await exec.getExecOutput('docker', ['version', '--format', '{{json . }}'], { silent: true, ignoreReturnCode: true }) + core.info(jsonLogOutput(stdout.trim())) + }) + + // docker info + await core.group(groupHeader('Docker (info)'), async () => { + const { stdout } = await exec.getExecOutput('docker', ['info', '--format', '{{json . }}'], { silent: true, ignoreReturnCode: true }) + core.info(jsonLogOutput(stdout.trim())) + }) + + // TODO json output - pretty print + // docker images + await core.group(groupHeader('Docker (images)'), async () => { + const { stdout } = await exec.getExecOutput('docker', ['image', 'ls', '--format', '{{json . }}'], { silent: true, ignoreReturnCode: true }) + core.info(stdout.trim()) + }) + + // docker daemon config + let dockerDaemonConfigPath = '/etc/docker/daemon.json' + if (platform === 'win32') { + dockerDaemonConfigPath = `${process.env.ProgramData}\\docker\\config\\daemon.json` + } + + if(fs.existsSync(dockerDaemonConfigPath)){ + await core.group(groupHeader('Docker (daemon config)'), async () => { + core.info(`path: ${dockerDaemonConfigPath}`) + core.info(jsonLogOutput(fs.readFileSync(core.toPlatformPath(dockerDaemonConfigPath), { encoding: 'utf-8' }).trim())) + }) + } + } + + if (platform === 'linux' || platform === 'darwin') { + await core.group(groupHeader('OS (file system)'), async () => { + await exec.exec('sh -e -c "df -aPh | jq -R -s \'[split(\\"\\n\\") | .[] | gsub(\\" +\\"; \\" \\") | split(\\" \\") | {filesystem: .[0], size: .[1], used: .[2], avail: .[3], use: .[4], mounted_on: .[5]}]\'"') + }) + + await core.group(groupHeader('OS (mounts)'), async () => { + await exec.exec('mount') + }) + } + + // TODO json output + // processor linux + if (platform === 'linux') { + await core.group(groupHeader('OS (processor)'), async () => { + await exec.exec('lscpu') + }) + } + + // TODO json output + // processor macos + if (platform === 'darwin') { + await core.group(groupHeader('OS (processor)'), async () => { + await exec.exec('sh -e -c "sysctl -a | grep machdep.cpu"') + }) + } + + if (platform === 'win32') { + // processor windows + await core.group(groupHeader('OS (processor)'), async () => { + await exec.exec('pwsh.exe', ['-Command', 'Get-CimInstance -Class Win32_Processor | Select-Object * -ExcludeProperty Cim* | ConvertTo-Json']) + }) + + await core.group(groupHeader('OS (computer system)'), async () => { + await exec.exec('pwsh.exe', ['-Command', 'Get-CimInstance -Class Win32_ComputerSystem | Select-Object * -ExcludeProperty Cim* | ConvertTo-Json']) + }) + + await core.group(groupHeader('OS (operating system)'), async () => { + await exec.exec('pwsh.exe', ['-Command', 'Get-CimInstance -Class Win32_OperatingSystem | Select-Object * -ExcludeProperty Cim* | ConvertTo-Json']) + }) + } + env: + # https://docs.github.com/en/actions/learn-github-actions/contexts + ACTION_DUMP_CONTEXT_GITHUB: ${{ toJson(github) }} + ACTION_DUMP_CONTEXT_ENV: ${{ toJson(env) }} + ACTION_DUMP_CONTEXT_VARS: ${{ inputs.vars-context }} + ACTION_DUMP_CONTEXT_JOB: ${{ toJson(job) }} + # ACTION_DUMP_CONTEXT_JOBS: ${{ inputs.jobs-context }} + ACTION_DUMP_CONTEXT_STEPS: ${{ toJson(steps) }} + ACTION_DUMP_CONTEXT_RUNNER: ${{ toJson(runner) }} + ACTION_DUMP_CONTEXT_SECRETS: ${{ inputs.secrets-context }} + ACTION_DUMP_CONTEXT_STRATEGY: ${{ toJson(strategy) }} + ACTION_DUMP_CONTEXT_MATRIX: ${{ toJson(matrix) }} + ACTION_DUMP_CONTEXT_NEEDS: ${{ inputs.needs-context }} + ACTION_DUMP_CONTEXT_INPUTS: ${{ inputs.inputs-context }} diff --git a/assets/images/demo.png b/assets/images/demo.png new file mode 100644 index 0000000..a44b81c Binary files /dev/null and b/assets/images/demo.png differ