From 01eccd122de6bf5afc4fe5b2af29d8ac1146cafe Mon Sep 17 00:00:00 2001 From: nataliagranato Date: Fri, 13 Sep 2024 21:27:57 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20Adicionar=20etapas=20de=20implanta?= =?UTF-8?q?=C3=A7=C3=A3o=20packages=20para=20produ=C3=A7=C3=A3o,=20staging?= =?UTF-8?q?=20e=20desenvolvimento?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/package-dev.yml | 75 +++++++++++++++++++ .../{environments.yml => package-prd.yml} | 2 +- .github/workflows/package-stg.yml | 75 +++++++++++++++++++ 3 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/package-dev.yml rename .github/workflows/{environments.yml => package-prd.yml} (97%) create mode 100644 .github/workflows/package-stg.yml diff --git a/.github/workflows/package-dev.yml b/.github/workflows/package-dev.yml new file mode 100644 index 0000000..107a5c9 --- /dev/null +++ b/.github/workflows/package-dev.yml @@ -0,0 +1,75 @@ +name: Melange, APKO e GitHub Container Registry em Desenvolvimento + +on: + push: + branches: + - 'main' + +jobs: + build: + name: Melange, APKO e GitHub Container Registry + runs-on: ubuntu-20.04 + permissions: + actions: read + contents: read + security-events: write + + steps: + # Checkout do código + - name: Checkout code + uses: actions/checkout@v4 + + # Configurar Docker Buildx + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Instalar Melange + - name: Install Melange + run: | + wget https://github.com/chainguard-dev/melange/releases/download/v0.11.2/melange_0.11.2_linux_386.tar.gz + tar -xzf melange_0.11.2_linux_386.tar.gz + cd melange_0.11.2_linux_386 + sudo mv melange /usr/local/bin/ + melange version + + # Instalar APKO + - name: Install APKO + run: | + wget https://github.com/chainguard-dev/apko/releases/download/v0.14.7/apko_0.14.7_linux_386.tar.gz + tar -xzf apko_0.14.7_linux_386.tar.gz + cd apko_0.14.7_linux_386 + sudo mv apko /usr/local/bin/ + apko version + + # Gerar chaves com Melange + - name: Generate keys with Melange + run: | + cd chainguard/environments/dev + melange keygen + + # Construir pacotes com Melange + - name: Build packages with Melange + run: | + cd chainguard/environments/dev + melange build melange-prod.yaml --runner docker --signing-key melange.rsa --arch amd64 + + # Construir imagem de container com APKO + - name: Build container image with APKO + run: | + cd chainguard/environments/dev + apko build apko-prod.yaml senhas senhas-prod.tar -k melange.rsa.pub --arch amd64 + + # Log in no GitHub Container Registry + - name: Log in to GitHub Container Registry + env: + CR_PAT: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + run: echo $CR_PAT | docker login ghcr.io -u nataliagranato --password-stdin + + # Load da imagem de container e push para o GitHub Container Registry + - name: Load Docker image + run: | + cd chainguard/environments/dev + docker load < senhas-prod.tar + docker images + docker tag senhas:latest-amd64 ghcr.io/nataliagranato/senhas-dev:$(date +%s) + docker push ghcr.io/nataliagranato/senhas-dev:$(date +%s) diff --git a/.github/workflows/environments.yml b/.github/workflows/package-prd.yml similarity index 97% rename from .github/workflows/environments.yml rename to .github/workflows/package-prd.yml index ad21016..c6ebd62 100644 --- a/.github/workflows/environments.yml +++ b/.github/workflows/package-prd.yml @@ -1,4 +1,4 @@ -name: Melange, APKO e GitHub Container Registry +name: Melange, APKO e GitHub Container Registry em Produção on: push: diff --git a/.github/workflows/package-stg.yml b/.github/workflows/package-stg.yml new file mode 100644 index 0000000..cfbe348 --- /dev/null +++ b/.github/workflows/package-stg.yml @@ -0,0 +1,75 @@ +name: Melange, APKO e GitHub Container Registry em Staging + +on: + push: + branches: + - 'main' + +jobs: + build: + name: Melange, APKO e GitHub Container Registry + runs-on: ubuntu-20.04 + permissions: + actions: read + contents: read + security-events: write + + steps: + # Checkout do código + - name: Checkout code + uses: actions/checkout@v4 + + # Configurar Docker Buildx + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Instalar Melange + - name: Install Melange + run: | + wget https://github.com/chainguard-dev/melange/releases/download/v0.11.2/melange_0.11.2_linux_386.tar.gz + tar -xzf melange_0.11.2_linux_386.tar.gz + cd melange_0.11.2_linux_386 + sudo mv melange /usr/local/bin/ + melange version + + # Instalar APKO + - name: Install APKO + run: | + wget https://github.com/chainguard-dev/apko/releases/download/v0.14.7/apko_0.14.7_linux_386.tar.gz + tar -xzf apko_0.14.7_linux_386.tar.gz + cd apko_0.14.7_linux_386 + sudo mv apko /usr/local/bin/ + apko version + + # Gerar chaves com Melange + - name: Generate keys with Melange + run: | + cd chainguard/environments/stg + melange keygen + + # Construir pacotes com Melange + - name: Build packages with Melange + run: | + cd chainguard/environments/stg + melange build melange-prod.yaml --runner docker --signing-key melange.rsa --arch amd64 + + # Construir imagem de container com APKO + - name: Build container image with APKO + run: | + cd chainguard/environments/stg + apko build apko-prod.yaml senhas senhas-prod.tar -k melange.rsa.pub --arch amd64 + + # Log in no GitHub Container Registry + - name: Log in to GitHub Container Registry + env: + CR_PAT: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + run: echo $CR_PAT | docker login ghcr.io -u nataliagranato --password-stdin + + # Load da imagem de container e push para o GitHub Container Registry + - name: Load Docker image + run: | + cd chainguard/environments/stg + docker load < senhas-prod.tar + docker images + docker tag senhas:latest-amd64 ghcr.io/nataliagranato/senhas-stg:$(date +%s) + docker push ghcr.io/nataliagranato/senhas-stg:$(date +%s)