|
| 1 | +name: Re-release CI |
| 2 | +run-name: Re-releasing - ${{ github.event.inputs.tag }} by @${{ github.actor }} |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + tag: |
| 8 | + description: 'Tag' |
| 9 | + required: true |
| 10 | + |
| 11 | +jobs: |
| 12 | + build-test: |
| 13 | + name: Build & Test |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Git checkout |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + ref: ${{ github.event.inputs.tag }} |
| 22 | + |
| 23 | + - name: Set up Go 1.23.0 |
| 24 | + uses: actions/setup-go@v5 |
| 25 | + with: |
| 26 | + go-version: '1.23.0' |
| 27 | + |
| 28 | + - name: Start MongoDB |
| 29 | + uses: supercharge/mongodb-github-action@1.11.0 |
| 30 | + with: |
| 31 | + mongodb-version: 7.0 |
| 32 | + |
| 33 | + - name: Build |
| 34 | + run: go build -v ./... |
| 35 | + |
| 36 | + - name: Test |
| 37 | + run: go test -p 1 -v ./... -coverprofile="coverage.out" |
| 38 | + env: |
| 39 | + GO_ENV: test |
| 40 | + MONGODB_URI: mongodb://127.0.0.1:27017 |
| 41 | + MONGO_DB: switcher-gitops-test |
| 42 | + GIT_TOKEN_PRIVATE_KEY: ${{ secrets.GIT_TOKEN_PRIVATE_KEY }} |
| 43 | + GIT_USER: ${{ secrets.GIT_USER }} |
| 44 | + GIT_TOKEN: ${{ secrets.GIT_TOKEN }} |
| 45 | + GIT_TOKEN_READ_ONLY: ${{ secrets.GIT_TOKEN_READ_ONLY }} |
| 46 | + GIT_REPO_URL: ${{ secrets.GIT_REPO_URL }} |
| 47 | + GIT_BRANCH: ${{ secrets.GIT_BRANCH }} |
| 48 | + |
| 49 | + docker: |
| 50 | + name: Publish Docker Image |
| 51 | + needs: [ build-test ] |
| 52 | + runs-on: ubuntu-latest |
| 53 | + |
| 54 | + steps: |
| 55 | + - name: Checkout code |
| 56 | + uses: actions/checkout@v4 |
| 57 | + with: |
| 58 | + fetch-depth: 0 |
| 59 | + ref: ${{ github.event.inputs.tag }} |
| 60 | + |
| 61 | + - name: Docker meta |
| 62 | + id: meta |
| 63 | + uses: docker/metadata-action@v5 |
| 64 | + with: |
| 65 | + images: trackerforce/switcher-gitops |
| 66 | + tags: ${{ github.event.inputs.tag }} |
| 67 | + |
| 68 | + - name: Set up QEMU |
| 69 | + uses: docker/setup-qemu-action@v3 |
| 70 | + |
| 71 | + - name: Set up Docker Buildx |
| 72 | + uses: docker/setup-buildx-action@v3 |
| 73 | + |
| 74 | + - name: Login to DockerHub |
| 75 | + uses: docker/login-action@v3 |
| 76 | + with: |
| 77 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 78 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 79 | + |
| 80 | + - name: Build and push |
| 81 | + uses: docker/build-push-action@v6 |
| 82 | + with: |
| 83 | + context: . |
| 84 | + push: true |
| 85 | + platforms: linux/amd64,linux/arm64 |
| 86 | + tags: ${{ steps.meta.outputs.tags }} |
| 87 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments