From 2bcd4b7e37aa4b7a2ecf7066ac27c29f6dd5a359 Mon Sep 17 00:00:00 2001 From: Ignasi Date: Tue, 25 Feb 2025 23:10:41 +0100 Subject: [PATCH] Push to Google Artifact Repository --- .github/workflows/gar.yml | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/gar.yml diff --git a/.github/workflows/gar.yml b/.github/workflows/gar.yml new file mode 100644 index 0000000..a6a57a7 --- /dev/null +++ b/.github/workflows/gar.yml @@ -0,0 +1,49 @@ +name: GAR Push + +on: + push: + +permissions: + contents: read + id-token: write # Required for OIDC authentication + +env: + GAR_REGION: us-east4 + PROJECT_ID: sandbox-298914 + GAR_REPOSITORY: docker-model-distribution + GAR_LOCATION: us-east4-docker.pkg.dev + +jobs: + verify-access: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Authenticate to Google Cloud + uses: google-github-actions/auth@v2 + with: + project_id: ${{ env.PROJECT_ID }} + workload_identity_provider: 'projects/981855438795/locations/global/workloadIdentityPools/model-distribution-pool/providers/model-distribution-github' + + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@v2 + + - name: Configure Docker for GAR + run: | + gcloud auth configure-docker ${{ env.GAR_LOCATION }} --quiet + + - name: Build and push image + run: | + # Build and push using existing Dockerfile + docker build -t ${{ env.GAR_LOCATION }}/${{ env.PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/test:latest . + docker push ${{ env.GAR_LOCATION }}/${{ env.PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/test:latest + + - name: Verify image + run: | + # Remove local image to ensure we're pulling from GAR + docker rmi ${{ env.GAR_LOCATION }}/${{ env.PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/test:latest + + # Pull the image back + docker pull ${{ env.GAR_LOCATION }}/${{ env.PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/test:latest + + # Run the container to verify + docker run ${{ env.GAR_LOCATION }}/${{ env.PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/test:latest \ No newline at end of file