Skip to content

Commit

Permalink
Move processes to reusable actions (#1266)
Browse files Browse the repository at this point in the history
Moved the SSH setup to a reusable action

---------

Co-authored-by: STEFANO BOSISIO <[email protected]>
  • Loading branch information
Steboss and STEFANO BOSISIO authored Jan 28, 2025
1 parent 1a13844 commit 45d5750
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 127 deletions.
32 changes: 32 additions & 0 deletions .github/actions/setup-ssh/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: 'Setup SSH'

description: 'Setup SSH agent and known hosts'

inputs:
ssh-private-key:
description: 'SSH private key'
required: true
ssh-known-hosts:
description: 'SSH Known Hosts entries'
required: true
outputs:
known-hosts-file:
description: 'Path to the SSH known hosts file'
value: ${{ steps.ssh-known-hosts.outputs.known_hosts_file }}

runs:
using: 'composite'
steps:
- name: Setup SSH agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ inputs.ssh-private-key }}

- name: Setup SSH known hosts
id: ssh-known-hosts
shell: bash
run: |
mkdir -p ~/.ssh
echo "${{ inputs.ssh-known-hosts }}" >> ~/.ssh/known_hosts
chmod 600 ~/.ssh/known_hosts
echo "known_hosts_file=$(realpath ~/.ssh/known_hosts)" >> $GITHUB_OUTPUT
26 changes: 9 additions & 17 deletions .github/workflows/_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,16 @@ jobs:
- name: Print environment variables
run: env

- name: Setup SSH agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Setup SSH known hosts
id: ssh-known-hosts
run: |
mkdir -p ~/.ssh
cat >> ~/.ssh/known_hosts << EOF
${{ vars.SSH_KNOWN_HOSTS }}
EOF
chmod 600 ~/.ssh/known_hosts
echo "FILE=$(realpath ~/.ssh/known_hosts)" >> $GITHUB_OUTPUT
- name: Check out the repository under ${GITHUB_WORKSPACE}
uses: actions/checkout@v4

- name: Setup SSH
id: setup-ssh
uses: ./.github/actions/setup-ssh
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh-known-hosts: ${{ vars.SSH_KNOWN_HOSTS }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
Expand Down Expand Up @@ -134,7 +126,7 @@ jobs:
labels: ${{ steps.mealkit-metadata.outputs.labels }}
ssh: default
secret-files: |
"SSH_KNOWN_HOSTS=${{ steps.ssh-known-hosts.outputs.FILE }}"
"SSH_KNOWN_HOSTS=${{ steps.setup-ssh.outputs.known-hosts-file }}"
build-args: |
BASE_IMAGE=${{ inputs.BASE_IMAGE }}
BAZEL_CACHE=${{ vars.BAZEL_REMOTE_CACHE_URL }}
Expand Down Expand Up @@ -167,7 +159,7 @@ jobs:
target: final
ssh: default
secret-files: |
"SSH_KNOWN_HOSTS=${{ steps.ssh-known-hosts.outputs.FILE }}"
"SSH_KNOWN_HOSTS=${{ steps.setup-ssh.outputs.known-hosts-file }}"
build-args: |
BASE_IMAGE=${{ inputs.BASE_IMAGE }}
BAZEL_CACHE=${{ vars.BAZEL_REMOTE_CACHE_URL }}
Expand Down
25 changes: 4 additions & 21 deletions .github/workflows/_publish_t5x_pax_results.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,12 @@ jobs:
publish:
runs-on: ubuntu-22.04
steps:
- name: Setup SSH agent
uses: webfactory/[email protected]
- name: Setup SSH
id: setup-ssh
uses: ./.github/actions/setup-ssh
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Setup SSH known hosts
id: ssh-known-hosts
run: |
mkdir -p ~/.ssh
cat >> ~/.ssh/known_hosts << EOF
${{ vars.SSH_KNOWN_HOSTS }}
EOF
chmod 600 ~/.ssh/known_hosts
echo "FILE=$(realpath ~/.ssh/known_hosts)" >> $GITHUB_OUTPUT
- name: Setup SSH config
id: ssh-config
run: |
mkdir -p ~/.ssh
cat >> ~/.ssh/config << EOF
${{ vars.SSH_CONFIG }}
EOF
chmod 600 ~/.ssh/config
ssh-known-hosts: ${{ vars.SSH_KNOWN_HOSTS }}

- name: Create dated folder and generate TensorBoard query URL
id: mkdir
Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/_runner_ondemand_slurm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,12 @@ jobs:
- name: Check out the repository under ${GITHUB_WORKSPACE}
uses: actions/checkout@v4

- name: Setup SSH agent
uses: webfactory/[email protected]
- name: Setup SSH
id: setup-ssh
uses: ./.github/actions/setup-ssh
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Setup SSH known hosts
id: ssh-known-hosts
run: |
mkdir -p ~/.ssh
cat >> ~/.ssh/known_hosts << EOF
${{ vars.SSH_KNOWN_HOSTS }}
EOF
chmod 600 ~/.ssh/known_hosts
echo "FILE=$(realpath ~/.ssh/known_hosts)" >> $GITHUB_OUTPUT
ssh-known-hosts: ${{ vars.SSH_KNOWN_HOSTS }}

- name: Labels and metadata
id: meta
Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/_test_maxtext.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,12 @@ jobs:
- name: Check out the repository under ${GITHUB_WORKSPACE}
uses: actions/checkout@v4

- name: Setup SSH agent
uses: webfactory/[email protected]
- name: Setup SSH
id: setup-ssh
uses: ./.github/actions/setup-ssh
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Setup SSH known hosts
id: ssh-known-hosts
run: |
mkdir -p ~/.ssh
cat >> ~/.ssh/known_hosts << EOF
${{ vars.SSH_KNOWN_HOSTS }}
EOF
chmod 600 ~/.ssh/known_hosts
echo "FILE=$(realpath ~/.ssh/known_hosts)" >> $GITHUB_OUTPUT
ssh-known-hosts: ${{ vars.SSH_KNOWN_HOSTS }}

- name: Labels and metadata
id: meta
Expand Down
20 changes: 6 additions & 14 deletions .github/workflows/_test_pax_rosetta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,15 @@ jobs:
- name: Print environment variables
run: env

- name: Setup SSH agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Check out the repository under ${GITHUB_WORKSPACE}
uses: actions/checkout@v4

- name: Setup SSH known hosts
id: ssh-known-hosts
run: |
mkdir -p ~/.ssh
cat >> ~/.ssh/known_hosts << EOF
${{ vars.SSH_KNOWN_HOSTS }}
EOF
chmod 600 ~/.ssh/known_hosts
echo "FILE=$(realpath ~/.ssh/known_hosts)" >> $GITHUB_OUTPUT
- name: Setup SSH
id: setup-ssh
uses: ./.github/actions/setup-ssh
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh-known-hosts: ${{ vars.SSH_KNOWN_HOSTS }}

- name: Labels and metadata
id: meta
Expand Down
18 changes: 5 additions & 13 deletions .github/workflows/_test_slurm_pyxis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,13 @@ jobs:
- name: Check out the repository under ${GITHUB_WORKSPACE}
uses: actions/checkout@v4

- name: Setup SSH agent
uses: webfactory/[email protected]
- name: Setup SSH
id: setup-ssh
uses: ./.github/actions/setup-ssh
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Setup SSH known hosts
id: ssh-known-hosts
run: |
mkdir -p ~/.ssh
cat >> ~/.ssh/known_hosts << EOF
${{ vars.SSH_KNOWN_HOSTS }}
EOF
chmod 600 ~/.ssh/known_hosts
echo "FILE=$(realpath ~/.ssh/known_hosts)" >> $GITHUB_OUTPUT
ssh-known-hosts: ${{ vars.SSH_KNOWN_HOSTS }}

- name: Labels and metadata
id: meta
shell: bash -x -e {0}
Expand Down
20 changes: 6 additions & 14 deletions .github/workflows/_test_t5x_rosetta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,16 @@ jobs:
steps:
- name: Print environment variables
run: env

- name: Setup SSH agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Check out the repository under ${GITHUB_WORKSPACE}
uses: actions/checkout@v4

- name: Setup SSH known hosts
id: ssh-known-hosts
run: |
mkdir -p ~/.ssh
cat >> ~/.ssh/known_hosts << EOF
${{ vars.SSH_KNOWN_HOSTS }}
EOF
chmod 600 ~/.ssh/known_hosts
echo "FILE=$(realpath ~/.ssh/known_hosts)" >> $GITHUB_OUTPUT
- name: Setup SSH
id: setup-ssh
uses: ./.github/actions/setup-ssh
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh-known-hosts: ${{ vars.SSH_KNOWN_HOSTS }}

- name: Labels and metadata
id: meta
Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/_test_upstream_pax.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,12 @@ jobs:
- name: Check out the repository under ${GITHUB_WORKSPACE}
uses: actions/checkout@v4

- name: Setup SSH agent
uses: webfactory/[email protected]
- name: Setup SSH
id: setup-ssh
uses: ./.github/actions/setup-ssh
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Setup SSH known hosts
id: ssh-known-hosts
run: |
mkdir -p ~/.ssh
cat >> ~/.ssh/known_hosts << EOF
${{ vars.SSH_KNOWN_HOSTS }}
EOF
chmod 600 ~/.ssh/known_hosts
echo "FILE=$(realpath ~/.ssh/known_hosts)" >> $GITHUB_OUTPUT
ssh-known-hosts: ${{ vars.SSH_KNOWN_HOSTS }}

- name: Labels and metadata
id: meta
Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/_test_upstream_t5x.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,12 @@ jobs:
- name: Check out the repository under ${GITHUB_WORKSPACE}
uses: actions/checkout@v4

- name: Setup SSH agent
uses: webfactory/[email protected]
- name: Setup SSH
id: setup-ssh
uses: ./.github/actions/setup-ssh
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Setup SSH known hosts
id: ssh-known-hosts
run: |
mkdir -p ~/.ssh
cat >> ~/.ssh/known_hosts << EOF
${{ vars.SSH_KNOWN_HOSTS }}
EOF
chmod 600 ~/.ssh/known_hosts
echo "FILE=$(realpath ~/.ssh/known_hosts)" >> $GITHUB_OUTPUT
ssh-known-hosts: ${{ vars.SSH_KNOWN_HOSTS }}

- name: Labels and metadata
id: meta
Expand Down

0 comments on commit 45d5750

Please sign in to comment.