Просмотр исходного кода

Merge pull request #1030 from porter-dev/porter-update-action_container

add porter-update-action_container
abelanger5 4 лет назад
Родитель
Сommit
f10ff02453

+ 1 - 1
.github/workflows/release.yaml

@@ -373,7 +373,7 @@ jobs:
           aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/o1j4x7p4
       - name: Build
         run: |
-          docker build . -t public.ecr.aws/o1j4x7p4/porter-cli:${{steps.tag_name.outputs.tag}} -t public.ecr.aws/o1j4x7p4/porter-cli:latest -f ./services/porter-cli-container/Dockerfile
+          docker build ./services/porter_cli_container -t public.ecr.aws/o1j4x7p4/porter-cli:${{steps.tag_name.outputs.tag}} -t public.ecr.aws/o1j4x7p4/porter-cli:latest -f ./services/porter_cli_container/Dockerfile
       - name: Push
         run: |
           docker push public.ecr.aws/o1j4x7p4/porter-cli:${{steps.tag_name.outputs.tag}}

+ 11 - 0
services/porter_cli_container/Dockerfile

@@ -0,0 +1,11 @@
+FROM ubuntu:latest
+
+COPY get-porter-cli.sh /scratch/
+
+RUN apt-get update && apt-get install -y curl unzip
+
+ARG VERSION
+
+RUN /scratch/get-porter-cli.sh
+
+ENTRYPOINT ["porter"]

+ 15 - 0
services/porter_cli_container/get-porter-cli.sh

@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+
+if [[ -z $VERSION ]]; then
+  name=$(curl -s https://api.github.com/repos/porter-dev/porter/releases/latest | grep "browser_download_url.*/porter_.*_Linux_x86_64\.zip" | cut -d ":" -f 2,3 | tr -d \")
+  name=$(basename "$name")
+  curl -L https://github.com/porter-dev/porter/releases/latest/download/"$name" --output "$name"
+else
+  name=porter-$VERSION.zip
+  curl -L https://github.com/porter-dev/porter/releases/download/"$VERSION"/porter_"$VERSION"_Linux_x86_64.zip --output "$name"
+fi
+
+unzip -a "$name"
+rm "$name"
+chmod +x ./porter
+mv ./porter /usr/local/bin/