summaryrefslogtreecommitdiff
path: root/.github/actions/setup/ubuntu/action.yml
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2023-06-29 10:02:23 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2023-06-30 11:18:06 +0900
commite8d629ed76cab8b17f82f024b6b5f7eddb71ab51 (patch)
tree2a169331e6109a58f441be9477fe3b3f543b7e9e /.github/actions/setup/ubuntu/action.yml
parentd3ff43852b22f5463d22aab390ef340d9ebe4b06 (diff)
refactor extract apt-get
Use composite action to reduce copy & paste.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7998
Diffstat (limited to '.github/actions/setup/ubuntu/action.yml')
-rw-r--r--.github/actions/setup/ubuntu/action.yml53
1 files changed, 53 insertions, 0 deletions
diff --git a/.github/actions/setup/ubuntu/action.yml b/.github/actions/setup/ubuntu/action.yml
new file mode 100644
index 0000000000..a9e5b41951
--- /dev/null
+++ b/.github/actions/setup/ubuntu/action.yml
@@ -0,0 +1,53 @@
+name: Setup ubuntu environment
+description: >-
+ At the beginning there was no way but to copy & paste `apt-get`
+ everywhere. But now that we have composite actions, it seems better
+ merge them into one.
+
+inputs:
+ arch:
+ required: false
+ default: ''
+ description: >-
+ Architecture. Because we run this on a GitHub-hosted runner
+ acceptable value for this input is very limited.
+
+outputs:
+ arch:
+ value: ${{ steps.uname.outputs.uname }}
+ description: >-
+ Actual architecture. This could be different from the one
+ passed to the `inputs.arch`. For instance giving `i386` to this
+ action yields `i686`.
+
+runs:
+ using: composite
+
+ steps:
+ - name: set SETARCH
+ shell: bash
+ run: echo "SETARCH=${setarch}" >> "$GITHUB_ENV"
+ env:
+ setarch: ${{ inputs.arch && format('setarch {0} --', inputs.arch) }}
+
+ - id: uname
+ name: uname
+ shell: bash
+ run: |
+ echo uname=`${SETARCH} uname -m` >> "$GITHUB_OUTPUT"
+ echo dpkg=`${SETARCH} uname -m | sed s/686/386/` >> "$GITHUB_OUTPUT"
+
+ - name: apt-get
+ shell: bash
+ env:
+ arch: ${{ inputs.arch && format(':{0}', steps.uname.outputs.dpkg) || '' }}
+ run: |
+ set -x
+ ${arch:+sudo dpkg --add-architecture ${arch#:}}
+ sudo apt-get update -qq || :
+ sudo apt-get install --no-install-recommends -qq -y -o=Dpkg::Use-Pty=0 \
+ ${arch:+cross}build-essential${arch/:/-} \
+ libssl-dev${arch} libyaml-dev${arch} libreadline6-dev${arch} \
+ zlib1g-dev${arch} libncurses5-dev${arch} libffi-dev${arch} \
+ autoconf ruby
+ sudo apt-get install -qq -y pkg-config${arch} || :