Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tmclaugh committed Sep 3, 2024
0 parents commit 0e86dcd
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Branch

on:
workflow_dispatch:
push:
branches:
- '*/*'

jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- name: Setup job workspace
uses: ServerlessOpsIO/gha-setup-workspace@v1

- name: Schema Validation
id: schema-validation
uses: dsanders11/[email protected]
with:
files: 'action.yaml'
schema: https://json.schemastore.org/github-action.json
59 changes: 59 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Main

on:
workflow_dispatch:
push:
branches:
- 'main'

jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- name: Setup job workspace
uses: ServerlessOpsIO/gha-setup-workspace@v1

- name: Schema Validation
id: schema-validation
uses: dsanders11/[email protected]
with:
files: 'action.yaml'
schema: https://json.schemastore.org/github-action.json

merge:
needs:
- build
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write

steps:
- name: Setup job workspace
uses: ServerlessOpsIO/gha-setup-workspace@v1
with:
checkout_fetch_depth: 0

- name: Merge branch
id: merge-branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Configuring git"
git config user.name "GitHub Actions"
git config user.email "<>"
echo "Checking out branch"
git fetch origin v1
git checkout v1
git reset --hard v1
echo "Merging branch"
git merge --no-ff $GITHUB_REF
echo "Pushing branch"
git push origin v1
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# gha-artifact-name

Output an artifact name for use across steps in a job.

This is a utility action created to ensure `ServerlessOpsIO/gha-setup-workspace` and `ServerlessOpsIO/gha-store-artifacts` generate the same artifact name by default. This action is intended to be used in a composite action and not directly in a workflow.

## Description

The `gha-artifact-name` action performs the following tasks:
1. Generates an artifact name based on the provided override or generates a default name.

## Inputs

- `artifact_name` (optional): Override the name of the artifact to use. Default is an empty string.

## Outputs

- `artifact_name`: The generated name of the artifact.

## Usage

for example usage see [ServerlessOps/gha-setup-workspace](https://github.com/ServerlessOpsIO/gha-setup-workspace/blob/main/action.yaml) or [ServerlessOps/gha-store-artifacts](https://github.com/ServerlessOpsIO/gha-store-artifacts/blob/main/action.yaml)

## Contributing

Contributions are welcome! Please open an issue or submit a pull request for any changes.

## Contact

For any questions or support, please open an issue in this repository.
35 changes: 35 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 'store-artifacts'
description: 'Store workspace artifacts'

inputs:
artifact_name_override:
description: Override name of artifact to use
required: false
default: ''

runs:
using: composite
steps:
- name: Check GitHub env set
id: check-github-env
if: ${{ ! env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('Please make sure to set the GitHub Action environment variable `GITHUB_REPOSITORY_OWNER_PART_SLUG_URL` set by using the `ServerlessOpsIO/gha-setup-workspace` or `rlespinasse/github-slug-action@v4` action')
- name: Set artifact name
id: set-artifact-name
shell: bash
run: |
if [ ${{ inputs.artifact_name_override }} != '' ]; then
name="${{ inputs.artifact_name_override }}";
else
name="${{ env.GITHUB_REPOSITORY_SLUG }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ github.run_number }}-${{ github.sha }}";
fi;
echo "artifact-name=$name" >> $GITHUB_OUTPUT
outputs:
artifact_name:
description: Name of artifact stored
value: ${{ steps.set-artifact-name.outputs.artifact-name }}

0 comments on commit 0e86dcd

Please sign in to comment.