Skip to content

Commit a6c3586

Browse files
Initial version (#1)
## Description - Initial version. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 1f2202a commit a6c3586

File tree

9 files changed

+236
-194
lines changed

9 files changed

+236
-194
lines changed

.github/workflows/Action-Test.yml

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,44 @@
1-
name: Action-Test
2-
3-
run-name: "Action-Test - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"
4-
5-
on: [pull_request]
6-
7-
concurrency:
8-
group: ${{ github.workflow }}-${{ github.ref }}
9-
cancel-in-progress: true
10-
11-
permissions:
12-
contents: read
13-
pull-requests: read
14-
15-
jobs:
16-
ActionTestBasic:
17-
name: Action-Test - [Basic]
18-
runs-on: ubuntu-latest
19-
steps:
20-
# Need to check out as part of the test, as its a local action
21-
- name: Checkout repo
22-
uses: actions/checkout@v4
23-
24-
- name: Action-Test
25-
uses: ./
26-
with:
27-
working-directory: ./tests
28-
subject: PSModule
1+
name: Action-Test
2+
3+
run-name: "Action-Test - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"
4+
5+
on: [pull_request]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
permissions:
12+
contents: read
13+
pull-requests: read
14+
15+
jobs:
16+
UploadArtifact:
17+
name: Upload Artifact
18+
runs-on: ubuntu-latest
19+
steps:
20+
# Need to check out as part of the test, as its a local action
21+
- name: Checkout repo
22+
uses: actions/checkout@v4
23+
24+
- name: Upload Artifact
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: Docs
28+
path: README.md
29+
30+
ActionTestBasic:
31+
name: Action-Test - [Basic]
32+
needs: UploadArtifact
33+
runs-on: ubuntu-latest
34+
steps:
35+
# Need to check out as part of the test, as its a local action
36+
- name: Checkout repo
37+
uses: actions/checkout@v4
38+
39+
- name: Action-Test
40+
uses: ./
41+
with:
42+
WorkflowRunID: ${{ github.run_id }}
43+
ArtifactName: Docs
44+
GITHUB_TOKEN: ${{ GITHUB.TOKEN }}

.github/workflows/Auto-Configure.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/Auto-Document.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/Auto-Release.yml

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
name: Auto-Release
2-
3-
run-name: "Auto-Release - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"
4-
5-
on:
6-
pull_request_target:
7-
branches:
8-
- main
9-
types:
10-
- closed
11-
- opened
12-
- reopened
13-
- synchronize
14-
- labeled
15-
16-
concurrency:
17-
group: ${{ github.workflow }}-${{ github.ref }}
18-
cancel-in-progress: true
19-
20-
permissions:
21-
contents: write # Required to create releases
22-
pull-requests: write # Required to create comments on the PRs
23-
24-
jobs:
25-
Auto-Release:
26-
runs-on: ubuntu-latest
27-
steps:
28-
- name: Checkout Code
29-
uses: actions/checkout@v4
30-
31-
- name: Auto-Release
32-
uses: PSModule/Auto-Release@v1
33-
env:
34-
GITHUB_TOKEN: ${{ github.token }}
1+
name: Auto-Release
2+
3+
run-name: "Auto-Release - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"
4+
5+
on:
6+
pull_request_target:
7+
branches:
8+
- main
9+
types:
10+
- closed
11+
- opened
12+
- reopened
13+
- synchronize
14+
- labeled
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
permissions:
21+
contents: write # Required to create releases
22+
pull-requests: write # Required to create comments on the PRs
23+
24+
jobs:
25+
Auto-Release:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout Code
29+
uses: actions/checkout@v4
30+
31+
- name: Auto-Release
32+
uses: PSModule/Auto-Release@v1
33+
env:
34+
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/Linter.yml

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
name: Linter
2-
3-
run-name: "Linter - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"
4-
5-
on: [pull_request]
6-
7-
concurrency:
8-
group: ${{ github.workflow }}-${{ github.ref }}
9-
cancel-in-progress: true
10-
11-
permissions:
12-
contents: read
13-
packages: read
14-
statuses: write
15-
16-
jobs:
17-
Lint:
18-
name: Lint code base
19-
runs-on: ubuntu-latest
20-
steps:
21-
- name: Checkout repo
22-
uses: actions/checkout@v4
23-
with:
24-
fetch-depth: 0
25-
26-
- name: Lint code base
27-
uses: super-linter/super-linter/slim@latest
28-
env:
29-
GITHUB_TOKEN: ${{ github.token }}
1+
name: Linter
2+
3+
run-name: "Linter - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"
4+
5+
on: [pull_request]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
permissions:
12+
contents: read
13+
packages: read
14+
statuses: write
15+
16+
jobs:
17+
Lint:
18+
name: Lint code base
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout repo
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Lint code base
27+
uses: super-linter/super-linter/slim@latest
28+
env:
29+
GITHUB_TOKEN: ${{ github.token }}
30+
VALIDATE_JSCPD: false

README.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,59 @@
1-
# Template-action
1+
# Download-CIArtifact
22

3-
A template repository for GitHub Actions
3+
An action to download an artifact from a GitHub workflow run. Its main use case is to download artifacts from a PR CI workflow run to be used in a CD workflow.
4+
As an example, terraform plans can be uploaded as artifacts in a PR CI workflow and then downloaded in a CD workflow to be applied, without having to re-run the terraform plan command, just reuse the plan from CI.
45

56
## Usage
67

78
### Inputs
89

9-
### Secrets
10+
| Name | Description | Required | Default |
11+
| - | - | - | - |
12+
| `WorkingDirectory` | The working directory where the artifact will be downloaded to. Default is the root of the repository. | No | |
13+
| `WorkflowID` | The filename or ID of the workflow to download the artifact from. You must provide either `WorkflowID` or `WorkflowRunID`. | No | '' |
14+
| `WorkflowRunID` | The ID of the workflow run where the artifact will be download from. You must provide either `WorkflowID` or `WorkflowRunID`. | No | '' |
15+
| `ArtifactName` | Name of the artifact to download. If unspecified, all artifacts for the run are downloaded. | Yes | |
16+
| `GITHUB_TOKEN` | The GitHub token used to authenticate with the GitHub API. | Yes | |
1017

1118
### Outputs
1219

20+
N/A
21+
1322
### Example
1423

24+
Run a workflow that downloads an artifact from another workflow run.
25+
It expects a workflow called `CI.yml` that produces an artifact called `docs`.
26+
It can also be run manually by providing the `WorkflowRunID` input. When run manually, it will not automatically check a PR for the artifact from its
27+
latest workflow run, but instead it will download the artifact from the specified workflow run.
28+
1529
```yaml
16-
Example here
30+
name: CD
31+
32+
on:
33+
workflow_dispatch:
34+
inputs:
35+
WorkflowRunID:
36+
description: The ID of the workflow run where the artifact will be download from.
37+
required: true
38+
push:
39+
branches:
40+
- main
41+
42+
jobs:
43+
publish:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Get PR info
47+
uses: PSModule/Download-CIArtifact@init
48+
with:
49+
WorkflowID: CI.yml
50+
WorkflowRunID: ${{ github.event.inputs.WorkflowRunID }}
51+
ArtifactName: docs
52+
GITHUB_TOKEN: ${{ github.token }}
53+
54+
- name: Do what you need with the files
55+
shell: pwsh
56+
run: |
57+
Get-ChildItem -Path $env:GITHUB_WORKSPACE | Select-Object -Property FullName
58+
1759
```

0 commit comments

Comments
 (0)