|
1 | 1 | name: CI |
2 | | -run-name: Publicación de la pagina web |
| 2 | +run-name: Publicación de la pagina web como un contenedor Docker |
| 3 | + |
| 4 | +# Trigger the workflow on push or merge |
3 | 5 | on: |
4 | 6 | push: |
5 | 7 | branches: |
6 | 8 | - master |
| 9 | + pull_request_target: |
| 10 | + types: closed |
| 11 | + branches: |
| 12 | + - master |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: '${{ github.workflow }} @ ${{ github.event.issue.number || github.sha || github.head_ref || github.ref }}-${{ github.event.schedule || github.event.comment.id || github.event.sender.login }}' |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + packages: write |
7 | 21 |
|
8 | 22 | jobs: |
9 | | - build: |
| 23 | + docker: |
| 24 | + if: ${{ github.event_name != 'pull_request_target' || github.event.pull_request.merged == true }} |
10 | 25 | runs-on: ubuntu-latest |
11 | | - environment: deploy |
12 | 26 | steps: |
13 | | - - name: Checkout the current branch |
14 | | - uses: actions/checkout@v3 |
15 | | - |
16 | | - - name: Initialize the ssh-agent |
17 | | - uses: webfactory/ssh-agent@v0.4.1 |
18 | | - with: |
19 | | - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} |
20 | | - |
21 | | - - name: Create the docker image |
22 | | - run: make init |
23 | | - |
24 | | - - name: Build the website |
25 | | - run: make build |
26 | | - |
27 | | - - name: Scan the host key |
28 | | - run: mkdir -p ~/.ssh/ && ssh-keyscan -p $DEPLOY_PORT -H $DEPLOY_SERVER >> ~/.ssh/known_hosts |
29 | | - env: |
30 | | - DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }} |
31 | | - DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }} |
32 | | - |
33 | | - - name: Deploy the website |
34 | | - run: >- |
35 | | - rsync -avx -e "ssh -p $DEPLOY_PORT" --delete --exclude '.ssh' public/ $DEPLOY_USERNAME@$DEPLOY_SERVER:$DEPLOY_PATH |
36 | | - env: |
37 | | - DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }} |
38 | | - DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }} |
39 | | - DEPLOY_USERNAME: ${{ secrets.DEPLOY_USERNAME }} |
40 | | - DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }} |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Downcase REPO variable |
| 30 | + run: | |
| 31 | + # Lowercase repository identifier (bash expansion) |
| 32 | + echo "REPO=${GITHUB_REPOSITORY,,}" >> "${GITHUB_ENV}" |
| 33 | +
|
| 34 | + - name: Set up QEMU |
| 35 | + uses: docker/setup-qemu-action@v3 |
| 36 | + |
| 37 | + - name: Set up Docker Buildx |
| 38 | + uses: docker/setup-buildx-action@v3 |
| 39 | + |
| 40 | + - name: Log in to ghcr |
| 41 | + uses: docker/login-action@v3 |
| 42 | + with: |
| 43 | + registry: ghcr.io |
| 44 | + username: ${{ github.actor }} |
| 45 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + |
| 47 | + - name: Build and push |
| 48 | + uses: docker/build-push-action@v5 |
| 49 | + with: |
| 50 | + push: true |
| 51 | + tags: | |
| 52 | + ghcr.io/${{ env.REPO }}:${{ github.ref_name }} |
| 53 | + ghcr.io/${{ env.REPO }}:${{ github.sha }} |
| 54 | + platforms: linux/amd64 |
| 55 | + |
0 commit comments