|
| 1 | +on: |
| 2 | + push: |
| 3 | + tags: |
| 4 | + - "v*" |
| 5 | +name: Create release |
| 6 | +env: |
| 7 | + REGISTRY: quay.io |
| 8 | + IMAGE_NAME: ${{ github.repository }} |
| 9 | +jobs: |
| 10 | + release: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Checkout code |
| 14 | + uses: actions/checkout@v2 |
| 15 | + - name: Generate Release Notes |
| 16 | + run: | |
| 17 | + release_notes=$(gh api repos/{owner}/{repo}/releases/generate-notes -F tag_name=${{ github.ref }} --jq .body) |
| 18 | + echo 'RELEASE_NOTES<<EOF' >> $GITHUB_ENV |
| 19 | + echo "${release_notes}" >> $GITHUB_ENV |
| 20 | + echo 'EOF' >> $GITHUB_ENV |
| 21 | + env: |
| 22 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + OWNER: ${{ github.repository_owner }} |
| 24 | + REPO: ${{ github.event.repository.name }} |
| 25 | + |
| 26 | + - name: Docker manager metadata |
| 27 | + id: meta |
| 28 | + uses: docker/metadata-action@v3 |
| 29 | + with: |
| 30 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 31 | + flavor: latest=false |
| 32 | + tags: type=ref,event=tag |
| 33 | + |
| 34 | + - name: Set the from image tag |
| 35 | + run: echo "FROM_TAG=sha-${GITHUB_SHA::8}" >> $GITHUB_ENV |
| 36 | + |
| 37 | + - name: Copy the image using skopeo |
| 38 | + run: skopeo copy --all --dest-creds="${DST_REG_USER}":"${DST_REG_PASS}" docker://"${SRC_IMAGE}" docker://"${DST_IMAGE}" |
| 39 | + env: |
| 40 | + SRC_IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.FROM_TAG }} |
| 41 | + DST_IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} |
| 42 | + DST_REG_USER: ${{ secrets.QUAY_USERNAME }} |
| 43 | + DST_REG_PASS: ${{ secrets.QUAY_PASSWORD }} |
| 44 | + |
| 45 | + - name: Create Release |
| 46 | + id: create_release |
| 47 | + uses: actions/create-release@v1 |
| 48 | + env: |
| 49 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + with: |
| 51 | + tag_name: ${{ github.ref }} |
| 52 | + release_name: ${{ github.ref }} |
| 53 | + body: ${{ env.RELEASE_NOTES }} |
| 54 | + draft: false |
| 55 | + prerelease: true |
0 commit comments