Skip to content

Commit

Permalink
Fix name
Browse files Browse the repository at this point in the history
  • Loading branch information
andistorm committed Sep 11, 2023
1 parent 91dcc8c commit cfd5bdf
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 15 deletions.
36 changes: 28 additions & 8 deletions .github/workflows/test-github-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,27 @@ jobs:
run: |
cat output.txt
test "$(cat output.txt)" = "Hello world"
test-pull-single-file:
test-pull-single-file-1:
runs-on: ubuntu-22.04
steps:
- name: Create simple template with variable
run: |
echo "Hello {{ name }}" > template.j2
- name: Create data file
run: |
echo "name: world" > data.yaml
- name: Render template
# LTODO: switch to main branch
uses: everest/everest-ci/github-actions/render-jinja2@feature/add-render-jinja2-action
with:
template_file: template.j2
data_file: data.yaml
output_file: output.txt
- name: Check output
run: |
cat output.txt
test "$(cat output.txt)" = "Hello world"
test-pull-single-file-2:
runs-on: ubuntu-22.04
steps:
- name: Setup SSH
Expand All @@ -65,7 +85,7 @@ jobs:
with:
# LTODO: switch to main branch
github_path: everest/everest-ci/.github/workflows/test-github-actions.yaml@feature/add-render-jinja2-action
output_path: output.txt
output_path: .
- name: Checkout everest-ci
uses: actions/checkout@v2
with:
Expand All @@ -89,17 +109,17 @@ jobs:
echo "output_directory: ${{ steps.pull-single-file.outputs.output_directory }}"
test "${{ steps.pull-single-file.outputs.output_directory }}" = "$(pwd)"
echo "output_filename: ${{ steps.pull-single-file.outputs.output_filename }}"
test "${{ steps.pull-single-file.outputs.output_filename }}" = "output.txt"
test "${{ steps.pull-single-file.outputs.output_filename }}" = "test-github-actions.yaml"
- name: Check output file
run: |
cat output.txt
test "$(cat output.txt)" = "$(cat everest-ci/.github/workflows/test-github-actions.yaml)"
test-configure-ssh:
cat ${{ steps.pull-single-file.outputs.output_filename }}
test "$(cat ${{ steps.pull-single-file.outputs.output_filename }})" = "$(cat everest-ci/.github/workflows/test-github-actions.yaml)"
test-configure-git:
runs-on: ubuntu-22.04
steps:
- name: Configure SSH
- name: Configure Git
# LTODO: switch to main branch
uses: everest/everest-ci/github-actions/configure-ssh@feature/add-render-jinja2-action
uses: everest/everest-ci/github-actions/configure-git@feature/add-render-jinja2-action
with:
email: compiler@pionix.de
name: Github Service Account
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Configure ssh email and name
description: Configure ssh email and name
name: Configure git email and name
description: Configure git email and name
inputs:
email:
description: 'Email'
Expand Down
21 changes: 16 additions & 5 deletions github-actions/pull-single-file/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ runs:
run: |
import os, pathlib
directory = None
if "${{ inputs.output_path }}".endswith('/'):
directory = pathlib.Path("${{ inputs.output_path }}")
output_path = "${{ inputs.output_path }}"
if output_path.endswith('/') or output_path == '.' or output_path == '..':
directory = pathlib.Path(output_path)
filename = "${{ steps.extracted.outputs.filename }}"
else:
directory = pathlib.Path("${{ inputs.output_path }}").parent
filename = pathlib.Path("${{ inputs.output_path }}").name
directory = pathlib.Path(output_path).parent
filename = pathlib.Path(output_path).name
directory.mkdir(parents=True, exist_ok=True)
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
f.write(f'directory={ directory.absolute() }\n')
Expand All @@ -73,4 +74,14 @@ runs:
git archive HEAD:${{ steps.extracted.outputs.directory }} ${{ steps.extracted.outputs.filename }} | tar -C ${{ steps.prepare-output.outputs.directory }} -xf -
cd ..
rm -rf tmp-repo
mv ${{ steps.prepare-output.outputs.directory }}/${{ steps.extracted.outputs.filename }} ${{ steps.prepare-output.outputs.directory }}/${{ steps.prepare-output.outputs.filename }}
- name: Rename file if necessary
shell: bash
run: |
directory="${{ steps.prepare-output.outputs.directory }}"
source="$directory/${{ steps.extracted.outputs.filename }}"
target="$directory/${{ steps.prepare-output.outputs.filename }}"
if test "$source" = "$target"; then
echo "File $source is already named $target"
else
mv $source $target
fi

0 comments on commit cfd5bdf

Please sign in to comment.