|
1 | | -name: compiler-api to Heroku CD |
| 1 | +name: Build and push Docker image to GitHub Container Registry |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: |
6 | | - - master |
| 5 | + branches: [master] |
| 6 | + tags: ["*"] |
7 | 7 | pull_request: |
8 | | - branches: |
9 | | - - master |
10 | | -#set environment variables |
| 8 | + branches: [master] |
| 9 | + |
11 | 10 | env: |
12 | | - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} |
13 | | - APP_NAME: ${{ 'xrpl-compiler-api' }} |
| 11 | + # Use docker.io for Docker Hub if empty |
| 12 | + REGISTRY: ghcr.io |
| 13 | + # github.repository as <account>/<repo> |
| 14 | + IMAGE_NAME: ${{ github.repository }} |
14 | 15 |
|
15 | 16 | jobs: |
16 | 17 | build: |
17 | | - name: Test build image |
18 | | - runs-on: ubuntu-18.04 |
| 18 | + name: Build Docker image |
| 19 | + runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + packages: write |
| 23 | + |
19 | 24 | steps: |
20 | | - # Clone the repository |
21 | 25 | - name: Checkout |
22 | | - uses: actions/checkout@v2 |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + # Set up BuildKit Docker container builder to be able to build |
| 29 | + # multi-platform images and export cache |
| 30 | + # https://github.com/docker/setup-buildx-action |
| 31 | + - name: Set up Docker Buildx |
| 32 | + uses: docker/setup-buildx-action@v3 |
23 | 33 |
|
24 | | - # - name: SSH Debug |
25 | | - # uses: lhotari/action-upterm@v1 |
| 34 | + # Login against a Docker registry except on PR |
| 35 | + # https://github.com/docker/login-action |
| 36 | + - name: Log into registry ${{ env.REGISTRY }} |
| 37 | + uses: docker/login-action@v3 |
| 38 | + with: |
| 39 | + registry: ${{ env.REGISTRY }} |
| 40 | + username: ${{ github.actor }} |
| 41 | + password: ${{ secrets.GITHUB_TOKEN }} |
26 | 42 |
|
27 | 43 | - name: Download bin.zip |
28 | 44 | uses: dsaltares/fetch-gh-release-asset@master |
29 | 45 | with: |
30 | | - repo: "XRPLF/xrpl-hooks-compiler" |
31 | | - version: "tags/v1.25" |
| 46 | + repo: "Xahau/xrpl-hooks-compiler" |
| 47 | + version: "tags/v1.27" |
32 | 48 | file: "bin.zip" |
33 | 49 | target: "./bin.zip" |
34 | 50 | token: ${{ secrets.GITHUB_TOKEN }} |
35 | 51 |
|
36 | | - # Uncomment this if you want to debug pipeline |
37 | | - # - name: SSH Debug |
38 | | - # uses: lhotari/action-upterm@v1 |
39 | | - |
40 | 52 | - name: Unzip binaries |
41 | 53 | run: | |
42 | 54 | unzip -o bin.zip |
43 | 55 |
|
44 | | - - name: Local build |
| 56 | + - name: Prepare build |
45 | 57 | run: | |
| 58 | + git submodule update --init --recursive compiler-api/clang/includes |
46 | 59 | cd docker |
47 | 60 | make dependencies |
48 | | - docker build . --tag web |
49 | 61 |
|
| 62 | + - name: Docker meta |
| 63 | + uses: docker/metadata-action@v5 |
| 64 | + with: |
| 65 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 66 | + tags: | |
| 67 | + type=ref,event=branch |
| 68 | + type=semver,pattern={{version}} |
| 69 | + type=semver,pattern={{major}}.{{minor}} |
| 70 | + type=semver,pattern={{major}} |
| 71 | + type=semver,pattern=latest |
| 72 | + type=sha,prefix=git- |
| 73 | + |
50 | 74 | # Build Docker image |
51 | | - - name: Docker build |
52 | | - if: success() && contains('refs/heads/master', github.ref) |
53 | | - run: docker login --username=_ --password=$HEROKU_API_KEY registry.heroku.com |
54 | | - |
55 | | - # Push the Docker image to Heroku Container Registry |
56 | | - - name: Publish |
57 | | - if: success() && contains('refs/heads/master', github.ref) |
58 | | - run: | |
59 | | - cd docker |
60 | | - make dependencies |
61 | | - heroku container:push web -a $APP_NAME |
62 | | - make clean |
63 | | - heroku container:release web -a $APP_NAME |
| 75 | + # Build and push Docker image with Buildx (don't push on PR) |
| 76 | + # https://github.com/docker/build-push-action |
| 77 | + - name: Build and push Docker image |
| 78 | + id: build-and-push |
| 79 | + uses: docker/build-push-action@v6 |
| 80 | + with: |
| 81 | + context: ./docker |
| 82 | + push: true |
| 83 | + tags: ${{ steps.image-tags.outputs.tags }} |
0 commit comments