|
| 1 | +name: integration-gcp |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: "0 6 * * *" |
| 7 | + # push: |
| 8 | + # branches: |
| 9 | + # - main |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +jobs: |
| 15 | + test: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + defaults: |
| 18 | + run: |
| 19 | + working-directory: ./tests/integration |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 |
| 23 | + - name: Set up Go |
| 24 | + uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 |
| 25 | + with: |
| 26 | + go-version: 1.20.x |
| 27 | + cache-dependency-path: tests/integration/go.sum |
| 28 | + - name: Authenticate to Google Cloud |
| 29 | + uses: google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033 # v1.1.1 |
| 30 | + id: 'auth' |
| 31 | + with: |
| 32 | + credentials_json: '${{ secrets.IRC_E2E_GOOGLE_CREDENTIALS }}' |
| 33 | + token_format: 'access_token' |
| 34 | + - name: Set up gcloud |
| 35 | + uses: google-github-actions/setup-gcloud@e30db14379863a8c79331b04a9969f4c1e225e0b # v1.1.1 |
| 36 | + - name: Set up QEMU |
| 37 | + uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0 |
| 38 | + - name: Set up Docker Buildx |
| 39 | + uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2.5.0 |
| 40 | + - name: Cache Docker layers |
| 41 | + uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 |
| 42 | + id: cache |
| 43 | + with: |
| 44 | + path: /tmp/.buildx-cache |
| 45 | + key: ${{ runner.os }}-buildx-ghcache-${{ github.sha }} |
| 46 | + restore-keys: | |
| 47 | + ${{ runner.os }}-buildx-ghcache- |
| 48 | + - name: Log into gcr.io |
| 49 | + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0 |
| 50 | + with: |
| 51 | + registry: gcr.io |
| 52 | + username: oauth2accesstoken |
| 53 | + password: ${{ steps.auth.outputs.access_token }} |
| 54 | + - name: Log into us-central1-docker.pkg.dev |
| 55 | + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0 |
| 56 | + with: |
| 57 | + registry: us-central1-docker.pkg.dev |
| 58 | + username: oauth2accesstoken |
| 59 | + password: ${{ steps.auth.outputs.access_token }} |
| 60 | + - name: Set dynamic variables in .env |
| 61 | + run: | |
| 62 | + cat > .env <<EOF |
| 63 | + export TF_VAR_tags='{"environment"="github", "ci"="true", "repo"="image-reflector-controller", "createdat"="$(date -u +x%Y-%m-%d_%Hh%Mm%Ss)"}' |
| 64 | + EOF |
| 65 | + - name: Print .env for dynamic tag value reference |
| 66 | + run: cat .env |
| 67 | + - name: Build controller |
| 68 | + run: | |
| 69 | + make docker-build IMG=fluxcd/image-reflector-controller:dev \ |
| 70 | + BUILD_PLATFORMS=linux/amd64 \ |
| 71 | + BUILD_ARGS="--cache-from=type=local,src=/tmp/.buildx-cache \ |
| 72 | + --cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max" |
| 73 | + working-directory: ./ |
| 74 | + - # Temp fix |
| 75 | + # https://github.com/docker/build-push-action/issues/252 |
| 76 | + # https://github.com/moby/buildkit/issues/1896 |
| 77 | + name: Move cache |
| 78 | + run: | |
| 79 | + rm -rf /tmp/.buildx-cache |
| 80 | + mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
| 81 | + - name: Run tests |
| 82 | + run: . .env && make test-gcp TEST_IMG=fluxcd/image-reflector-controller:dev |
| 83 | + env: |
| 84 | + TF_VAR_gcp_project_id: ${{ vars.TF_VAR_gcp_project_id }} |
| 85 | + TF_VAR_gcp_region: ${{ vars.TF_VAR_gcp_region }} |
| 86 | + TF_VAR_gcp_zone: ${{ vars.TF_VAR_gcp_zone }} |
0 commit comments