Skip to content

Commit

Permalink
seventh test for build and push
Browse files Browse the repository at this point in the history
  • Loading branch information
leoBitto committed Oct 12, 2024
1 parent 117017e commit e74fdcd
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 474 deletions.
94 changes: 64 additions & 30 deletions .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,26 @@ name: Test Config and Artifact Mechanism

on:
workflow_dispatch:
inputs:
tag:
description: "Docker image tag"
required: true
default: "latest"

env:
REGISTRY: ghcr.io

jobs:
# Job 1: Creazione dei file di configurazione

create-config:
runs-on: ubuntu-latest

steps:
- name: Creazione della directory di configurazione
- name: Create config directory
run: mkdir -p config

# Creazione del file principale di configurazione (.cfg)
- name: Creazione del file principale di configurazione (.cfg)

- name: Create main config file (django.cfg)
run: |
echo "DEBUG=${{ secrets.DEBUG }}" >> config/django.cfg
echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> config/django.cfg
Expand All @@ -33,59 +41,85 @@ jobs:
echo "EMAIL=${{ secrets.EMAIL }}" >> config/django.cfg
echo "DOMAIN=${{ secrets.DOMAIN }}" >> config/django.cfg
# Creazione del file di configurazione per Postgres (db.cfg)
- name: Creazione del file di configurazione per Postgres (db.cfg)
- name: Creation of config file for Postgres (db.cfg)
run: |
echo "POSTGRES_DB=${{ secrets.POSTGRES_DB }}" >> config/db.cfg
echo "POSTGRES_USER=${{ secrets.POSTGRES_USER }}" >> config/db.cfg
echo "POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}" >> config/db.cfg
echo "SQL_HOST=${{ secrets.SQL_HOST }}" >> config/db.cfg
echo "SQL_PORT=${{ secrets.SQL_PORT }}" >> config/db.cfg
# Creazione del file di configurazione per Gold Postgres (gold.cfg)
- name: Creazione del file di configurazione per Gold Postgres (gold.cfg)
- name: Creation of config file for Gold Postgres (gold.cfg)
run: |
echo "GOLD_POSTGRES_DB=${{ secrets.GOLD_POSTGRES_DB }}" >> config/gold.cfg
echo "GOLD_POSTGRES_USER=${{ secrets.GOLD_POSTGRES_USER }}" >> config/gold.cfg
echo "GOLD_POSTGRES_PASSWORD=${{ secrets.GOLD_POSTGRES_PASSWORD }}" >> config/gold.cfg
echo "GOLD_SQL_HOST=${{ secrets.GOLD_SQL_HOST }}" >> config/gold.cfg
echo "GOLD_SQL_PORT=${{ secrets.GOLD_SQL_PORT }}" >> config/gold.cfg
# Salva i file di configurazione come artifact
- name: Salva file di configurazione come artifact
- name: Save config files as artifact
uses: actions/upload-artifact@v4
with:
name: config-files
path: ./config/

# Job 2: Lettura e visualizzazione degli artifacts
read-config:

build_and_push:
runs-on: ubuntu-latest
needs: create-config
needs: create-config

steps:
- name: Scarica i file di configurazione

- name: Checkout the repo
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GITHUB_TOKEN }}


- name: Download configuration files
uses: actions/download-artifact@v4
with:
name: config-files
path: ./downloaded-config/

# Verifica il percorso di scaricamento e memorizzalo
- name: Verifica e memorizza il percorso di scaricamento
run: echo "ARTIFACT_PATH=$(pwd)/downloaded-config/" >> $GITHUB_ENV

- name: Verify and memorize path of download
run: echo "ARTIFACT_PATH=$(pwd)/config/" >> $GITHUB_ENV

# Lista dei file scaricati
- name: Lista dei file scaricati
run: ls -R ${{ env.ARTIFACT_PATH }}

- name: Display content of configuration files
run: |
cat ${{ env.ARTIFACT_PATH }}django.cfg
cat ${{ env.ARTIFACT_PATH }}db.cfg
cat ${{ env.ARTIFACT_PATH }}gold.cfg
# Mostra il contenuto del file principale di configurazione (.cfg)
- name: Mostra il contenuto del file principale di configurazione (.cfg)
run: cat ${{ env.ARTIFACT_PATH }}django.cfg
- name: Build Docker image using Docker Compose
run: docker compose -f docker-compose.dev.yml build

# Mostra il contenuto del file di configurazione per Postgres (db.cfg)
- name: Mostra il contenuto del file di configurazione per Postgres (db.cfg)
run: cat ${{ env.ARTIFACT_PATH }}db.cfg

- name: Verify Docker image creation
run: docker images

# Mostra il contenuto del file di configurazione per Gold Postgres (gold.cfg)
- name: Mostra il contenuto del file di configurazione per Gold Postgres (gold.cfg)
run: cat ${{ env.ARTIFACT_PATH }}gold.cfg

- name: Set lower case owner and repo names
run: |
echo "OWNER_LC=${{ github.repository_owner,, }}" >>${GITHUB_ENV}
echo "REPO_NAME_LC=${{ github.repository,, }}" >>${GITHUB_ENV}
- name: Tag image for GHCR
run: |
docker tag webapp_django ${{ env.REGISTRY }}/${OWNER_LC}/${REPO_NAME_LC}:${{ inputs.tag }}
- name: Log in to GitHub Container Registry (GHCR)
run: echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin


- name: Push image to GHCR
run: |
docker push ${{ env.REGISTRY }}/${OWNER_LC}/${REPO_NAME_LC}:${{ inputs.tag }}
79 changes: 0 additions & 79 deletions .github/workflows/non-functioning_server_setup _orchestrator.yml

This file was deleted.

Loading

0 comments on commit e74fdcd

Please sign in to comment.