test pca #103
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Upload to GCP Bucket Workflow | |
on: | |
push: | |
branches: [main, citest] | |
workflow_dispatch: | |
jobs: | |
upload_to_gcp: | |
runs-on: ubuntu-22.04 | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
# Step 2: Set up Python environment | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
# Step 3: Install Google Cloud CLI | |
- name: Install Google Cloud CLI | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y google-cloud-cli | |
# Step 4 | |
- name: Decode and Write GCP Service Account Key | |
run: | | |
echo "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}" | base64 -d > /tmp/gcp-key.json | |
shell: bash | |
# Step 5: Authenticate using the Temporary File | |
- name: Authenticate with GCP | |
env: | |
GOOGLE_APPLICATION_CREDENTIALS: /tmp/gcp-key.json | |
run: gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} | |
# Step 6 | |
- name: Set GCP Project ID | |
run: gcloud config set project ${{ secrets.GCP_PROJECT_ID }} | |
# Step 7: Upload Artifacts to GCP Bucket | |
- name: Upload Artifacts | |
env: | |
GCS_BUCKET_NAME: ${{ secrets.GCS_BUCKET_NAME }} | |
run: | | |
gsutil -m cp -r artifacts/* gs://${GCS_BUCKET_NAME}/artifacts/ | |
gsutil -m cp -r pipeline/airflow/dags/* gs://${GCS_BUCKET_NAME}/airflow-dags/ | |
# Step 8 | |
- name: Remove Broken Symbolic Links | |
run: | | |
find . -xtype l -delete | |
# Step 9: Bucket with Directory Structure | |
- name: Upload All Files to GCP Bucket | |
env: | |
GCS_BUCKET_NAME: ${{ secrets.GCS_BUCKET_NAME }} | |
run: | | |
gsutil -m rsync -r . gs://${GCS_BUCKET_NAME}/GitHub/ | |
# Step 10: Verify Upload | |
- name: Verify GCP Bucket Upload | |
env: | |
GCS_BUCKET_NAME: ${{ secrets.GCS_BUCKET_NAME }} | |
run: | | |
echo "Listing files in GCS bucket:" | |
gsutil ls gs://${GCS_BUCKET_NAME}/ |