diff --git a/.github/workflows/gar.yml b/.github/workflows/gar.yml new file mode 100644 index 0000000..e93c67d --- /dev/null +++ b/.github/workflows/gar.yml @@ -0,0 +1,50 @@ +name: GAR Push + +on: + push: + workflow_dispatch: + +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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8dcbbbc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM alpine:latest +CMD ["echo", "Hello from container"] \ No newline at end of file