|
| 1 | +name: CI for releases |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 0 * * 0' # every Sunday at midnight |
| 6 | + |
| 7 | +jobs: |
| 8 | + build-and-push-docker-image: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + permissions: |
| 11 | + contents: read |
| 12 | + packages: write |
| 13 | + env: |
| 14 | + IMAGE_NAME: "reversed-ssh-tunnel" # can't contain uppercases |
| 15 | + steps: |
| 16 | + - |
| 17 | + name: Checkout repository |
| 18 | + uses: actions/checkout@v3 |
| 19 | + - |
| 20 | + name: Set up QEMU |
| 21 | + uses: docker/setup-qemu-action@v2 |
| 22 | + - |
| 23 | + name: Set up Docker Buildx |
| 24 | + uses: docker/setup-buildx-action@v2 |
| 25 | + - |
| 26 | + name: Login to GitHub Container Registry |
| 27 | + uses: docker/login-action@v2 |
| 28 | + with: |
| 29 | + registry: ghcr.io |
| 30 | + username: ${{ github.actor }} |
| 31 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + - |
| 33 | + name: Login to DockerHub |
| 34 | + uses: docker/login-action@v2 |
| 35 | + with: |
| 36 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 37 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 38 | + - |
| 39 | + name: Get latest tag |
| 40 | + id: latest_tag |
| 41 | + run: echo ::set-output name=tag::$(git describe --tags $(git rev-list --tags --max-count=1)) |
| 42 | + - |
| 43 | + name: Extract metadata (tags, labels) for Docker |
| 44 | + id: meta |
| 45 | + uses: docker/metadata-action@v4 |
| 46 | + with: |
| 47 | + images: | |
| 48 | + ghcr.io/${{ github.REPOSITORY_OWNER }}/${{ env.IMAGE_NAME }} |
| 49 | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }} |
| 50 | + tags: | |
| 51 | + ${{ steps.latest_tag.outputs.tag }} |
| 52 | + latest |
| 53 | + - |
| 54 | + name: Build and push |
| 55 | + uses: docker/build-push-action@v3 |
| 56 | + with: |
| 57 | + context: . |
| 58 | + file: ./Dockerfile |
| 59 | + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 |
| 60 | + push: true |
| 61 | + tags: ${{ steps.meta.outputs.tags }} |
| 62 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments